Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to hard code a password in a vba code.
Is there a way to make that password not decipherable/accessible to someone looking at the password. Just locking the VBA code from viewing is not good enough. Many thanks, Dan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could obfuscate it simply with a rotating algorithm like so
Public Function Encrypt(ByRef InputVal As String, _ Optional ByVal NumBase As Long = 13) Dim i As Long For i = 1 To Len(InputVal) Mid(InputVal, i, 1) = Chr(Asc(Mid(InputVal, i, 1)) + NumBase) Next i Encrypt = InputVal End Function Public Function decrypt(ByRef InputVal As String, _ Optional ByVal NumBase As Long = 13) Dim i As Long For i = 1 To Len(InputVal) Mid(InputVal, i, 1) = Chr(Asc(Mid(InputVal, i, 1)) - NumBase) Next i decrypt = InputVal End Function Sub Test() MsgBox "Encrypted: " & Encrypt("A test value") MsgBox "Decrypted: " & decrypt(Encrypt("A test value")) End Sub -- __________________________________ HTH Bob "Dan" wrote in message ... I need to hard code a password in a vba code. Is there a way to make that password not decipherable/accessible to someone looking at the password. Just locking the VBA code from viewing is not good enough. Many thanks, Dan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Anyone who can unlock the VBA could see the password no problem.
Even if you stored the PW outside of the VBA in (eg) a compiled dll, you still have to get it into the VBA at some point. Tim "Dan" wrote in message ... I need to hard code a password in a vba code. Is there a way to make that password not decipherable/accessible to someone looking at the password. Just locking the VBA code from viewing is not good enough. Many thanks, Dan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hard code month in Excel | Excel Discussion (Misc queries) | |||
Not Hard Code If | Excel Discussion (Misc queries) | |||
Hard Code DLL Reference in VBA | Excel Programming | |||
Hard Code DLL Reference in VBA | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |