Posts Tagged ‘cypher

03
Apr
09

[VB.Net] String XOR

This XOR is slightly more useful, you can encrypt a string using a byte as the key:

    Public Function StringXOR(ByVal str1 As String, ByVal XORByte As Byte) As String
        StringXOR = ""
        For i As Integer = 0 To str1.Length - 1
            StringXOR &= CChar(ChrW(Asc(str1(i)) Xor XORByte))
        Next
    End Function

Usage:

Debug.WriteLine(StringXOR("sim0n", 222))

Would Output:
­·³î°

and so

Debug.WriteLine(StringXOR("­•³î°", 222))

Would Output:
­sim0n

Advertisements