Skip to content

Commit f9ece38

Browse files
committed
Added VB.NET implementation
1 parent 40db272 commit f9ece38

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi
99
- [Dart](Dart/xorencryption.dart)
1010
- [F#](F%23/Program.fs) by [pawelizycki](https://github.com/pawelizycki)
1111
- [Groovy](Groovy/XOREncryption.groovy)
12-
- [Java \(Android Compatible\)](Java \(Android compatible\)/XOREncryption.java)
12+
- [Java \(Android Compatible\)](Java \(Android compatible\)/XOREncryption.java)
1313
- [JavaScript \(Node.js Compatible\)](JavaScript/XOREncryption.js)
1414
- [Objective-C](Objective-C/main.m)
1515
- [Python](Python/XOREncryption.py)
16+
- [Visual Basic.NET](VB.NET/XORCrypto.vb)
1617

1718
This implementation goes beyond the basic single-key model to use multiple keys in a particular sequence, making it that much more difficult to brute-force.
1819

VB.NET/XORCrypto.vb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Module XORCrypto
2+
3+
Sub Main()
4+
Dim input As String = Console.ReadLine()
5+
Dim output As String = encryptDecrypt(input)
6+
Console.WriteLine("Input : " & input)
7+
Console.WriteLine("Output : " & output)
8+
Dim rett As String = encryptDecrypt(output)
9+
Console.WriteLine("RoundAbout : " & rett)
10+
Console.ReadLine()
11+
End Sub
12+
13+
Private Function encryptDecrypt(input As String) As String
14+
Dim key As Char() = {"K"c, "C"c, "Q"c}
15+
'Any chars will work, in an array of any size
16+
Dim output As Char() = New Char(input.Length - 1) {}
17+
For i As Integer = 0 To input.Length - 1
18+
output(i) = ChrW(AscW(input(i)) Xor AscW(key(i Mod key.Length)))
19+
'CharW(CharCode As Integer) As Char : Returns the character associated with the specified character code
20+
'AscW([String] As Char) As Integer : Returns an integer value representing the character code corresponding to a character
21+
Next
22+
Return New String(output)
23+
End Function
24+
25+
End Module

0 commit comments

Comments
 (0)