CryptDecrypt




Function EncryptPassword(Number As Byte, _
DecryptedPassword As String) As String
Dim Password As String, Counter As Byte
Dim Temp As Integer
Counter = 1
Do Until Counter = Len(DecryptedPassword) + 1
Temp = Asc(Mid(DecryptedPassword, Counter, 1))
'see if even

If Counter Mod 2 = 0 Then
Temp = Temp - Number
Else
Temp = Temp + Number
End If
Temp = Temp Xor (10 - Number)
Password = Password & Chr$(Temp)
Counter = Counter + 1
Loop
EncryptPassword = Password
End Function

'To decrypt the password, use the following code:

Function DecryptPassword(Number As Byte, _
EncryptedPassword As String) As String
Dim Password As String, Counter As Byte
Dim Temp As Integer
Counter = 1
Do Until Counter = Len(EncryptedPassword) + 1
Temp = Asc(Mid(EncryptedPassword, _
Counter, 1)) Xor (10 - Number)
'see if even

If Counter Mod 2 = 0 Then
Temp = Temp + Number
Else
Temp = Temp - Number
End If
Password = Password & Chr$(Temp)
Counter = Counter + 1
Loop
DecryptPassword = Password
End Function

Both of the following functions take two parameters:
Number, and the Password string to be Encrypted/Decrypted.
Number is used to alternatively shift each ASCII character
in Password up or down by that amount. It may be a good
idea to leave Number in the range of 1 to 10 so you don't
have to check for invalid ASCII values.
To encrypt a password, use the following code:










( cryptdecrypt.html )- by Paolo Puglisi - Modifica del 17/12/2023