Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Public Function Encryption(ByVal Input As String) As String 'creates a new function that allows a value parameter to be encrypted
- Dim tempCharacter As Char 'declares a character variable for a temporary character to be used to store each individual encrypted character
- Dim current As Char 'declares a character variable that will be used to store the current character being viewed in the string for each loop repitition
- Dim encryptedData As String 'declares a new string variable that will be used to store the encrypted string
- Dim i As Integer 'declares an integer variable that will be used in a loop
- encryptedData = String.Empty 'clears any data that may be stored in the encryptedData variable so that it can be used
- For i = 0 To Input.Length - 1 'starts a new for loop that will loop for every character in the input string
- current = Input(i) 'current variable will store the current loop's character in the string
- tempCharacter = Chr((Asc(current) + 4) * 2) 'the current character is converted to the ASCII value, then 4 is added, then multiplied by 2, then converted back to a character in order to be stored in the tempCharacter variable
- encryptedData = encryptedData & tempCharacter 'for each loop repeat, the encryptedData variable has each encrypted character added to it in order to produce the final encrypted sring
- Next 'repeats loop
- Encryption = encryptedData 'the encrypted data is returned by the function
- End Function
- Public Function Decryption(ByVal input As String) As String
- Dim tempCharacter As Char 'declares a character variable for a temporary character to be used to store each individual decrypted character
- Dim current As Char 'declares a character variable that stores will be used to store the current character being viewed in the string for each loop repitition
- Dim decryptedData As String 'declares a new string variable that will be used to store the decrypted string
- Dim i As Integer 'declares an integer variable that will be used in a loop
- decryptedData = String.Empty 'clears any data that may be stored in the decryptedData variable so that it can be used
- For i = 0 To input.Length - 1 'starts a new for loop that will loop for every character in the input string
- current = input(i) 'current variable will store the current loop's character in the string
- tempCharacter = Chr((Asc(current) / 2) - 4) 'the current character is converted to the ASCII value, then it is divided by 2, and subtracted by 4, then converted back to a character in order to be stored in the tempCharacter variable
- decryptedData = decryptedData & tempCharacter 'for each loop repeat, the decryptedData variable has each decrypted character added to it in order to produce the final decrypted sring
- Next 'repeats loop
- Decryption = decryptedData 'the decrypted data is returned by the function
- End Function
- End Module
Add Comment
Please, Sign In to add comment