Re: Xor encryption
 From: rossum <rossum48@xxxxxxxxxxxx>
 Date: Mon, 12 Mar 2007 09:24:09 +0000
On 12 Mar 2007 00:50:12 0700, cvschie@xxxxxxxxx wrote:
On 8 mrt, 19:29, rossum <rossu...@xxxxxxxxxxxx> wrote:I don't know VB, but for safety's sake I would put
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
Checksum = 0
in here.
For Each Character In sWhy convert to a string at this stage? You have not finished
Checksum = Checksum Xor Convert.ToByte(Character)
Next
Return Checksum.ToString("X2")
calculating the checksum yet so it would be better to keep it as a
number and return an Integer from your function rather than a string.
End FunctionNo, your function as given will return "61" if passed "a". Either you
With this function the alphabet returns:
a: 61 must be 15
need to post more code, or you have forgotten to use the pattern
involving hex 74 in your code.
rossum
b: 62 must be 16[snip]
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
not the value's I wanted...
.
 FollowUps:
 Re: Xor encryption
 From: cvschie
 Re: Xor encryption
 References:
 Xor encryption
 From: cvschie
 Re: Xor encryption
 From: rossum
 Re: Xor encryption
 From: cvschie
 Xor encryption
 Prev by Date: Re: Xor encryption
 Next by Date: Re: Image Encryption
 Previous by thread: Re: Xor encryption
 Next by thread: Re: Xor encryption
 Index(es):
Relevant Pages
