Hi
Can someone give me or redirect me to a simple but 100% efficient Xor encryption function ? (for text strings)
I dont care much about security because Im not trying to protect anything valuable but I need to bee working 100% of the times since, depending of the key you provide sometines the result is not back-convertable (at least this happens to the only xor function that I found on the net)
I hope I made myself clear.
Here is something you might like… it is RC4 encryption
text can have special characters (such as line breaks) and no problem
The Base64 is used to make it all 7bit ASCII characters allowing it to be stored in standard DB text fields if required.
Dim MM As MemoryBlock = strData
Dim MM2 As New MemoryBlock(LenB(strData))
Dim memAsciiArray(255) As Integer
Dim memKeyArray(255) As Integer
Dim memJump As Integer
Dim memTemp As Integer
Dim memY As Integer
Dim intKeyLength As Integer
Dim intIndex As Integer
Dim intT As Integer
Dim intX As Integer
intKeyLength = Len(strKey)
For intIndex = 0 To 255
memKeyArray(intIndex) = Asc(Mid(strKey, ((intIndex) Mod (intKeyLength)) + 1, 1))
Next
For intIndex = 0 To 255
memAsciiArray(intIndex) = intIndex
Next
For intIndex = 0 To 255
memJump = (memJump + memAsciiArray(intIndex) + memKeyArray(intIndex)) Mod 256
memTemp = memAsciiArray(intIndex)
memAsciiArray(intIndex) = memAsciiArray(memJump)
memAsciiArray(memJump) = memTemp
Next
intIndex = 0
memJump = 0
For intX = 1 To MM2.Size
intIndex = (intIndex + 1) Mod 256
memJump = (memJump + memAsciiArray(intIndex)) Mod 256
intT = (memAsciiArray(intIndex) + memAsciiArray(memJump)) Mod 256
memTemp = memAsciiArray(intIndex)
memAsciiArray(intIndex) = memAsciiArray(memJump)
memAsciiArray(memJump) = memTemp
memY = memAsciiArray(intT)
mm2.Byte(intX - 1) = bitwise.bitxor(Val("&h" + Hex(MM.Byte(IntX - 1))), bitwise.bitxor(memTemp,memY))
Next
Return MM2