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

0 Responses to “[VB.Net] String XOR”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: