XOR Encryption

email me

'characters to hex
mymessage1 = "Hello World"

mykey1 = "supersecret"

strR=""
strQ=""
toHex mymessage1
msgbox mymessage1 & " = " & trim(strR)
mymessagetohex1 = trim(strR)
mymessage1 = trim(mymessage1)

strR=""
strQ=""
toHex mykey1
msgbox mykey1 & " = " & trim(strR)
mykeytohex1 = trim(strR)
mykey1 = trim(mykey1)

function toHex(x)
if x <> "" then
strQ= Left(x,1)
strQ= Asc(strQ)
strQ= Hex(strQ)
strR=strR & strQ & ""'add space here
toHex mid(x,2)
else
trim(strR)
end if
end function

Dim myKeycode : myKeycode = mykey1
Dim myEncryptedText, myDecryptedText

XOREncrypt mymessage1
msgbox "ciphertext = " & myEncryptedText

XORDecrypt myEncryptedText
msgbox "decrypted text = " & myDecryptedText

Function XOREncrypt(byVal plaintext)
' Declare necessary vars
Dim xorValue1, xorValue2, i
Dim hexVal
For i = 1 To Len(plaintext)
xorValue1 = Asc(Mid(plaintext, i, 1))
'msgbox "plaintext: " & xorValue1 & " location: " & i
xorValue2 = Asc(Mid(myKeycode, (i Mod LEN(myKeycode) + 1), 1))
'msgbox "my key: " & xorValue2 & " location: " & i
hexVal = Hex(xorValue1 Xor xorValue2)
If Len(hexVal) = 1 Then hexVal = "0" & hexVal
myEncryptedText = myEncryptedText & hexVal
Next
XOREncrypt = myEncryptedText
End Function

function XORDecrypt(byval myEncryptedText)
' Declare necessary vars
Dim xorValue1, xorValue2, i
For i = 1 To (Len(myEncryptedText) / 2)
xorValue1 = CInt("&H" & (Mid(myEncryptedText, (2 * i) - 1, 2)))
xorValue2 = Asc(Mid(myKeycode, CInt(((i Mod Len(myKeycode)) + 1)), 1))
myDecryptedText = myDecryptedText + Chr(xorValue1 Xor xorValue2)
Next
XORDecrypt = myDecryptedText
End function

WScript.Quit(0)