Sunday, July 22, 2007

Password Encryption And Decryption

encrypt_password accepts a string as the password and returns the encrypted value of password

Public Shared Function encrypt_password(ByVal password As String)
Dim pass_word() As Char
Dim fixed, total As String
Dim ch As Char
fixed = "120"
pass_word = password
For Each ch In pass_word
total = String.Concat(total, Chr(Asc(ch) + Asc(fixed)))
Next
Return total
End Function

Public Shared Function decrypt_password(ByVal password As String)
Dim pass_word() As Char
Dim fixed, total As String
Dim ch1 As Char
fixed = "120"
pass_word = password
For Each ch1 In pass_word
total = String.Concat(total, Chr(Asc(ch1) - Asc(fixed)))
Next
Return total
End Function

No comments: