by Anonymous (267 Submissions)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 1st November 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Quick and easy encryption
Public Function Encrypt(ByVal Plain As String)
Dim Letter As String
For I = 1 To Len(Plain)
Letter = Mid$(Plain, I, 1)
Mid$(Plain, I, 1) = Chr(Asc(Letter) + 1)
Next I
Encrypt = Plain
End Function
'Here's the Decryption function:
Public Function Decrypt(ByVal Encrypted As String)
Dim Letter As String
For I = 1 To Len(Encrypted)
Letter = Mid$(Encrypted, I, 1)
Mid$(Encrypted, I, 1) = Chr(Asc(Letter) - 1)
Next I
Decrypt = Encrypted
End Function
'here is sample code to test it....
Dim strMessage As String
strMessage = "Original:"
strMessage = strMessage & "This is a test" & vbCrLf
strMessage = strMessage & vbCrLf & "Encrypted:"
strMessage = strMessage & Encrypt("This is a test") & vbCrLf
strMessage = strMessage & vbCrLf & "Un-Encrypted:"
strMessage = strMessage & Decrypt(Encrypt("This is a test"))
MsgBox strMessage