Reputation: 661
Dim Key As Long
Packet = txtSend.Text
PacketLength = Len(txtSend.Text)
key = &H82381AC + PacketLength * "17"
For ix = 1 To PacketLength - 1
OneCharacter = Mid$(Packet, ix, 1)
NewCharacter = Asc(OneCharacter) Xor key And &H1F
key = key * "13" Xor &H43B
Next ix
The loop will run about 3 times then overflow. I guess no matter what u do xor will result in Byte,Integer or Long. CDec(Key) will not work I need a way to bypass this so i can Xor large numbers.
Upvotes: 0
Views: 397
Reputation: 112762
You can only XOR integer numbers, not strings. If you want to encrypt a string using XOR, do so by applying XOR character by character to the character codes
Public Function Encrypt(ByVal s As String) As String
Const key As String = "r5^245ADh3%^ywftGY53Gsdr245^Tsfdgw45^fGqw4%6243TefgH563&ot7y"
Dim i As Integer
For i = 1 To Len(s)
Mid(s, i, 1) = Chr(Asc(Mid(s, i, 1)) Xor Asc(Mid(key, i, 1)))
Next i
Return s
End Function
Upvotes: 1