ElliottE4

Untitled

Apr 7th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.06 KB | None | 0 0
  1. Module Module1
  2.     Public Function Encryption(ByVal Input As String) As String 'creates a new function that allows a value parameter to be encrypted
  3.  
  4.         Dim tempCharacter As Char 'declares a character variable for a temporary character to be used to store each individual encrypted character
  5.         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
  6.         Dim encryptedData As String 'declares a new string variable that will be used to store the encrypted string
  7.         Dim i As Integer 'declares an integer variable that will be used in a loop
  8.  
  9.         encryptedData = String.Empty 'clears any data that may be stored in the encryptedData variable so that it can be used
  10.  
  11.         For i = 0 To Input.Length - 1 'starts a new for loop that will loop for every character in the input string
  12.  
  13.             current = Input(i) 'current variable will store the current loop's character in the string
  14.  
  15.             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
  16.  
  17.             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
  18.  
  19.         Next 'repeats loop
  20.  
  21.         Encryption = encryptedData 'the encrypted data is returned by the function
  22.  
  23.     End Function
  24.  
  25.     Public Function Decryption(ByVal input As String) As String
  26.  
  27.         Dim tempCharacter As Char 'declares a character variable for a temporary character to be used to store each individual decrypted character
  28.         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
  29.         Dim decryptedData As String 'declares a new string variable that will be used to store the decrypted string
  30.         Dim i As Integer 'declares an integer variable that will be used in a loop
  31.  
  32.         decryptedData = String.Empty 'clears any data that may be stored in the decryptedData variable so that it can be used
  33.  
  34.         For i = 0 To input.Length - 1 'starts a new for loop that will loop for every character in the input string
  35.  
  36.             current = input(i) 'current variable will store the current loop's character in the string
  37.  
  38.             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
  39.  
  40.             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
  41.  
  42.         Next 'repeats loop
  43.  
  44.         Decryption = decryptedData 'the decrypted data is returned by the function
  45.  
  46.     End Function
  47.  
  48. End Module
  49.  
Add Comment
Please, Sign In to add comment