Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard code month in Excel Rachel Costanza Excel Discussion (Misc queries) 6 November 7th 08 02:04 AM
Not Hard Code If FIRSTROUNDKO via OfficeKB.com Excel Discussion (Misc queries) 3 July 10th 07 04:11 PM
Hard Code DLL Reference in VBA alex Excel Programming 4 June 10th 04 05:05 PM
Hard Code DLL Reference in VBA alex Excel Programming 0 June 10th 04 01:20 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"