Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class clsEncryption 'encryption class
- Public Function encrypt(ByVal originalString As String) As String 'function that returns a string
- Dim indexChar As Char 'character that is being encrypted
- Dim newChar As Char 'encrypted character
- Dim encryptedString As String 'the encrypted string
- Dim counter As Integer 'current character to look at in the string
- encryptedString = String.Empty 'an empty string
- For counter = 0 To originalString.Length - 1 'for every character in the string
- indexChar = originalString(counter) 'the character in the original string
- newChar = Chr(Asc(indexChar) + 5) 'the new ASCII character value for the string
- encryptedString = encryptedString & newChar 'add the new character
- Next
- encrypt = encryptedString 'return encrypted string
- End Function
- Public Function decrypt(ByVal encryptedString As String) As String 'function that returns a string
- Dim indexChar As Char 'character being decrypted
- Dim newChar As Char 'decrypted character
- Dim originalString As String 'the unencrypted string
- Dim counter As Integer 'current character to look at in the string
- originalString = String.Empty 'an empty string
- For counter = 0 To encryptedString.Length - 1 'for every character in the string
- indexChar = encryptedString(counter) 'the character in the encrypted string
- newChar = Chr(Asc(indexChar) - 5) 'the original ASCII character value for the string
- originalString = originalString & newChar 'add the new character
- Next
- decrypt = originalString 'return the decrypted string
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement