![]() |
hard code a password in a vba code
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 |
hard code a password in a vba code
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 |
hard code a password in a vba code
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 |
All times are GMT +1. The time now is 05:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com