Re: Xor encryption
- From: cvschie@xxxxxxxxx
- Date: 12 Mar 2007 00:50:12 -0700
On 8 mrt, 19:29, rossum <rossu...@xxxxxxxxxxxx> wrote:
On 8 Mar 2007 05:18:19 -0800, cvsc...@xxxxxxxxx wrote:
Hi,
To communicate with a LED sign I need to calculate a checksum of the
message.
If message is 'bas' the checksum is '04'.
How can I calculate the checksum? (I need it in VB.net, bus other
language is no problem)
Or do I need a key to Xor with?
Examples: (last 2 chars =checksum)
a15
'a' = 0x61 = 0110 0001
0x15 = 0001 0101 (checksum)
XOR = 0111 0100 = 0x74
b16
'b' = 0x62 = 0110 0010
0x16 = 0001 0110 (checksum)
XOR = 0111 0100 = 0x74
Do you see the pattern?
c17
d10
e11
f12
g13
h1C
i1D
j1E
k1F
bas04
'b' = 0x62 = 0110 0010
'a' = 0x61 = 0110 0001
's' = 0x73 = 0111 0011
0x04 = 0000 0100 (checksum)
XOR = 0111 0100 = 0x74
Do you see the pattern?
bes00
besss00
bessst74
bessstt00
Thanks in advance
You can calculate the XOR of all the characters in your string, call
this X. You also have a checksum, which you do not know, and you
should be able to work out what (X xor checksum) is from the pattern
above. Note that X xor (X xor checksum) = checksum and you have
solved your problem.
This is not an encryption by the way, it is just a simple XOR
checksum.
rossum
Thanks for the support.
Meanwhile I got the communication protocol. Now I now for sure the
cecksum is calculated with Xor, but how exactly is not mentioned.
I still didn't figure out how to calculated it.
I tried this in VB.NET:
Function xorit(ByVal s As String) As String
Dim Character As Char
Dim Checksum As Integer
For Each Character In s
Checksum = Checksum Xor Convert.ToByte(Character)
Next
Return Checksum.ToString("X2")
End Function
With this function the alphabet returns:
a: 61 must be 15
b: 62 must be 16
c: 63 must be 17
d: 64 must be 10
e: 65 must be 11
f: 66 must be 12
g: 67 must be 13
h: 68 must be 1C
i: 69 must be 1D
j: 6A
k: 6B
l: 6C
m: 6D
n: 6E
o: 6F
p: 70
q: 71
r: 72
s: 73
t: 74
u: 75
v: 76
w: 77
x: 78
y: 79
z: 7A
not the value's I wanted...
.
- Follow-Ups:
- Re: Xor encryption
- From: rossum
- Re: Xor encryption
- References:
- Xor encryption
- From: cvschie
- Re: Xor encryption
- From: rossum
- Xor encryption
- Prev by Date: Re: JSH: Good news!
- Next by Date: Re: Xor encryption
- Previous by thread: Re: Xor encryption
- Next by thread: Re: Xor encryption
- Index(es):
Relevant Pages
|