Advertisement
Guest User

CTX1 encryption algorithm

a guest
Dec 6th, 2013
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.97 KB | None | 0 0
  1. Imports System.Text
  2.  
  3. Module Module1
  4.     Sub Main()
  5.         'Constant Keys
  6.         Dim KEY1 = &HA5 'Constant Start XOR KEY
  7.         Dim KEY2 = &H4  '2nd part XOR
  8.         Dim KEY3 = &HF  '2nd part XOR
  9.         Dim KEY4 = &H41 '2nd part XOR
  10.  
  11.         Dim PASSWORD() As Byte 'Stored as UNICODE format. 'Encoding.ASCII.GetString()
  12.         Dim XORARRAY() As Integer 'Used to store the first round which is used with the 2nd round
  13.         Dim ENCRYPTEDSTRING() As Integer 'The encrypted password
  14.  
  15.         'Get password input
  16.         Console.Write("Password: ")
  17.         PASSWORD = Encoding.Unicode.GetBytes(Console.ReadLine())
  18.  
  19.         'Begin Encryption
  20.         ReDim Preserve XORARRAY(0) 'Resize the Array
  21.         XORARRAY(0) = PASSWORD(0) Xor KEY1
  22.  
  23.         'Round 1 Encryption - Results used in Round 2
  24.         For i As Integer = 0 To ((PASSWORD.Length / 2) + ((PASSWORD.Length / 2) - 2))
  25.             ReDim Preserve XORARRAY(i + 1) 'Resize the Array
  26.             XORARRAY(i + 1) = XORARRAY(i) Xor KEY1
  27.             XORARRAY(i + 1) = XORARRAY(i + 1) Xor PASSWORD(i + 1)
  28.         Next
  29.  
  30.         'Round 2 Encryption
  31.         Dim y = 0
  32.         For i As Integer = 0 To (XORARRAY.Length - 1)
  33.             ReDim Preserve ENCRYPTEDSTRING(y) 'Resize the Array
  34.             ENCRYPTEDSTRING(y) = XORARRAY(i) >> KEY2
  35.             ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) And KEY3
  36.             ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) + KEY4
  37.  
  38.             y = y + 1
  39.             ReDim Preserve ENCRYPTEDSTRING(y) 'Resize the Array
  40.             ENCRYPTEDSTRING(y) = XORARRAY(i) And KEY3
  41.             ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) + KEY4
  42.             y = y + 1
  43.         Next
  44.         'End Encryption
  45.  
  46.         Console.Write("Encrypted String: ")
  47.         For i As Integer = 0 To (ENCRYPTEDSTRING.Length - 1)
  48.             Console.Write(Chr(ENCRYPTEDSTRING(i)))
  49.         Next
  50.         Console.WriteLine("")
  51.         Console.WriteLine("Press ENTER to quit")
  52.         Console.ReadLine()
  53.     End Sub
  54.  
  55. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement