VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Quick and easy encryption

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

Rate 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

Download this snippet    Add to My Saved Code

Quick and easy encryption Comments

No comments have been posted about Quick and easy encryption. Why not be the first to post a comment about Quick and easy encryption.

Post your comment

Subject:
Message:
0/1000 characters