Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text
- Module Module1
- Sub Main()
- 'Constant Keys
- Dim KEY1 = &HA5 'Constant Start XOR KEY
- Dim KEY2 = &H4 '2nd part XOR
- Dim KEY3 = &HF '2nd part XOR
- Dim KEY4 = &H41 '2nd part XOR
- Dim PASSWORD() As Byte 'Stored as UNICODE format. 'Encoding.ASCII.GetString()
- Dim XORARRAY() As Integer 'Used to store the first round which is used with the 2nd round
- Dim ENCRYPTEDSTRING() As Integer 'The encrypted password
- 'Get password input
- Console.Write("Password: ")
- PASSWORD = Encoding.Unicode.GetBytes(Console.ReadLine())
- 'Begin Encryption
- ReDim Preserve XORARRAY(0) 'Resize the Array
- XORARRAY(0) = PASSWORD(0) Xor KEY1
- 'Round 1 Encryption - Results used in Round 2
- For i As Integer = 0 To ((PASSWORD.Length / 2) + ((PASSWORD.Length / 2) - 2))
- ReDim Preserve XORARRAY(i + 1) 'Resize the Array
- XORARRAY(i + 1) = XORARRAY(i) Xor KEY1
- XORARRAY(i + 1) = XORARRAY(i + 1) Xor PASSWORD(i + 1)
- Next
- 'Round 2 Encryption
- Dim y = 0
- For i As Integer = 0 To (XORARRAY.Length - 1)
- ReDim Preserve ENCRYPTEDSTRING(y) 'Resize the Array
- ENCRYPTEDSTRING(y) = XORARRAY(i) >> KEY2
- ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) And KEY3
- ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) + KEY4
- y = y + 1
- ReDim Preserve ENCRYPTEDSTRING(y) 'Resize the Array
- ENCRYPTEDSTRING(y) = XORARRAY(i) And KEY3
- ENCRYPTEDSTRING(y) = ENCRYPTEDSTRING(y) + KEY4
- y = y + 1
- Next
- 'End Encryption
- Console.Write("Encrypted String: ")
- For i As Integer = 0 To (ENCRYPTEDSTRING.Length - 1)
- Console.Write(Chr(ENCRYPTEDSTRING(i)))
- Next
- Console.WriteLine("")
- Console.WriteLine("Press ENTER to quit")
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement