Advertisement
ZeekoSec

AsciiSwitch (Simple string encryption) VB.NET

Apr 9th, 2015
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2.  Function AsciiSwitch(InputString As String, ValueToAdd As Integer) As String
  3.         Dim OutputString As String = String.Empty
  4.         Dim c As Char
  5.         For i = 0 To Len(InputString) - 1
  6.             c = InputString.Substring(i, 1)
  7.             OutputString += Chr(Asc(c) + ValueToAdd)
  8.         Next
  9.  
  10.         Return OutputString
  11.     End Function
  12.  
  13. 'Calling the function
  14.  
  15.    'lblDecrypted.Text = AsciiSwitchBack(lblEncrypted.Text, 19)
  16.   'lblDecrypted.Text = AsciiSwitch(lblEncrypted.Text, -19)
  17.  
  18.  
  19. 'AsciiSwitchMod
  20.  
  21.  Function AsciiSwitchWithMod(InputString As String, ValueToAdd As Integer, ModValue As Integer) As String
  22.         Dim OutputString As String = String.Empty
  23.         Dim c As Char
  24.         For i = 0 To Len(InputString) - 1
  25.             c = InputString.Substring(i, 1)
  26.             If i Mod 5 = 0 Then
  27.                 OutputString += Chr(Asc(c) + ValueToAdd + ModValue)
  28.             Else
  29.                 OutputString += Chr(Asc(c) + ValueToAdd)
  30.             End If
  31.         Next
  32.  
  33.         Return OutputString
  34.     End Function
  35.  
  36.   ' Calling the function
  37.  
  38. lblEncrypted.Text = AsciiSwitchWithMod(txtInput.Text, 19, 7)
  39. lblDecrypted.Text = AsciiSwitchWithMod(lblEncrypted.Text, -19, -7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement