a simple function to encrypt / decrypt data
Private Function EncryptDecrypt(Byval InBuffer As String,Optional Byval key
As String="yourPersonalKey") As String
Dim Key As String, HHH As String, SBox As String, Texti As String
Dim Text1 As String
Dim t As Long, i As Long, C As Long, k1 As Long, k2 As Long
Dim k As Long, F As Long, j As Long, h As Long, s As Long
On Error Resume Next
Key = Password
For i = 1 To 256
k1 = VBA.Asc(Mid(Key, i, 1))
k2 = VBA.Asc(VBA.Mid(Key, k1 + i Mod Len(Key), 1))
C = (C ^ 2) Mod (C * 2)
C = C + (k1 * 2 - k2) Mod 256
C = C + (k1 * 2 + k2 * 2) Mod (k1 * 2)
C = C + (k1 * 2 + k2 * 2) Mod (k2 * 2)
C = C Xor i Mod 256
HHH = HHH & VBA.Chr(C Mod 256 + 1)
Next i
SBox = HHH
Key = Password
Texti = InBuffer
Text1 = ""
For i = 1 To Len(InBuffer)
C = VBA.Asc(VBA.Mid(InBuffer, i, 1)) - 1
k = VBA.Asc(VBA.Mid(Key, i Mod Len(Key), 1))
F = k
j = (j + i) Mod 256
t = (t + j) Mod 256
h = (h + Asc(Mid(SBox, t, 1)) + Asc(Mid(SBox, j, 1))) Mod 256
s = (s + Asc(Mid(SBox, h + t Mod 256, 1)) + Asc(Mid(SBox, h + i, 1)) +
Asc(Mid(SBox, h + j, 1))) Mod 256
F = (F Xor i Xor j Xor t Xor h Xor s) Mod 255
F = (F Xor j Xor t Xor h Xor s) Mod 256
F = (F Xor t Xor h Xor s) Mod 255
F = (F Xor h Xor s) Mod 256
F = (F Xor s) Mod 255
F = F + (i + j + t + h + s Mod 256)
F = F + (j + t + h + s Mod 256)
F = F + (t + h + s Mod 256)
F = F + (h + s Mod 256)
F = F + (s Mod 256)
F = F Mod 256
C = C Xor F
C = (C Mod 256) + 1
VBA.Mid(Texti, i, 1) = VBA.Chr(C)
Next i
Stream = Texti
End Function
all you have to do is remember the key!
hth
Pieter
ctdak said:
I am already using the "password" input mask for the actual logon form.
What I'm talking about here is the form where certain assigned users
maintain the user logon info. They can see and modify user logon passwords.
However, I don't want them seeing and modifying the password of the
application administrator. That's the one I want to hide. Perhaps I can do
this with VBA code - by replacing or hiding the display of the password
control for that user only?