Advertisement
UsernameHere1

Untitled

Feb 21st, 2024
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.73 KB | None | 0 0
  1. Public Class clsEncryption 'encryption class
  2.     Public Function encrypt(ByVal originalString As String) As String 'function that returns a string
  3.         Dim indexChar As Char 'character that is being encrypted
  4.         Dim newChar As Char 'encrypted character
  5.         Dim encryptedString As String 'the encrypted string
  6.         Dim counter As Integer 'current character to look at in the string
  7.         encryptedString = String.Empty 'an empty string
  8.         For counter = 0 To originalString.Length - 1 'for every character in the string
  9.             indexChar = originalString(counter) 'the character in the original string
  10.             newChar = Chr(Asc(indexChar) + 5) 'the new ASCII character value for the string
  11.             encryptedString = encryptedString & newChar 'add the new character
  12.         Next
  13.         encrypt = encryptedString 'return encrypted string
  14.     End Function
  15.  
  16.     Public Function decrypt(ByVal encryptedString As String) As String 'function that returns a string
  17.         Dim indexChar As Char 'character being decrypted
  18.         Dim newChar As Char 'decrypted character
  19.         Dim originalString As String 'the unencrypted string
  20.         Dim counter As Integer 'current character to look at in the string
  21.         originalString = String.Empty 'an empty string
  22.         For counter = 0 To encryptedString.Length - 1 'for every character in the string
  23.             indexChar = encryptedString(counter) 'the character in the encrypted string
  24.             newChar = Chr(Asc(indexChar) - 5) 'the original ASCII character value for the string
  25.             originalString = originalString & newChar 'add the new character
  26.         Next
  27.         decrypt = originalString 'return the decrypted string
  28.     End Function
  29. End Class
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement