Thursday, December 1, 2011

Encrypt and Decrypt - Simple VB6

Public Function Encrypt(Name As String, Key As Long) As String
Dim v As Long, c1 As String, z As String
For v = 1 To Len(Name)
c1 = Asc(Mid(Name, v, 1))
c1 = Chr(c1 + Key) ' private key here !
z = z & c1
Next v
Encrypt = z
End Function

Public Function Decrypt(Name As String, Key As Long) As String
Dim v As Long, c1 As String, z As String
For v = 1 To Len(Name)
c1 = Asc(Mid(Name, v, 1))
c1 = Chr(c1 - Key) ' private key here !
z = z & c1
Next v
Decrypt = z
End Function

No comments:

Post a Comment