Re: Xor encryption

On 12 Mar 2007 00:50:12 -0700, cvschie@xxxxxxxxx wrote:

On 8 mrt, 19:29, rossum <rossu...@xxxxxxxxxxxx> wrote:
On 8 Mar 2007 05:18:19 -0800, cvsc...@xxxxxxxxx wrote:


To communicate with a LED sign I need to calculate a checksum of the
If message is 'bas' the checksum is '04'.
How can I calculate the checksum? (I need it in, bus other
language is no problem)
Or do I need a key to Xor with?

Examples: (last 2 chars =checksum)


'a' = 0x61 = 0110 0001
0x15 = 0001 0101 (checksum)
XOR = 0111 0100 = 0x74


'b' = 0x62 = 0110 0010
0x16 = 0001 0110 (checksum)
XOR = 0111 0100 = 0x74

Do you see the pattern?


'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?


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


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
I don't know VB, but for safety's sake I would put
Checksum = 0
in here.

For Each Character In s
Checksum = Checksum Xor Convert.ToByte(Character)
Return Checksum.ToString("X2")
Why convert to a string at this stage? You have not finished
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 Function

With this function the alphabet returns:

a: 61 must be 15
No, your function as given will return "61" if passed "a". Either you
need to post more code, or you have forgotten to use the pattern
involving hex 74 in your code.


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

not the value's I wanted...


Relevant Pages

  • Re: Crypto Mini-FAQ
    ... >> often that attacks are possible. ... >> checksum is linear. ... Nikita Borisov, Ian Goldberg, and David Wagner. ... linear checksums commute with xor. ...
  • Re: Cant understand this code snippet
    ... I only know it's trying to XOR the process ID. ... ps -A lists all the processes on a Unix machine. ... giving you a list of random longs. ... It causes pack to compute a checksum out of those ...
  • Re: Sending commands to a GPS module
    ... I know the Doc's say Xor with characters between the $ and * how ever, ... each char maybe with FF and then summing.. ... variable and store result to the variable, convert checksum to ... control characters). ...
  • Re: Need Help With Decription
    ... every string wich is send the the LED has a sort of ... XOR all characters including the checksum character and compare ... I know it is encrypted with XOR. ... Select one of your examples above and XOR all characters of the message + the ...
  • Re: Better verification: checksum vs. xor
    ... Is it better to compare the data against a checksum or an xor of the ... Of course an xor will give a multi-way parity check and a sum will mix ... The behavior of this function under the first set of considerations ... byte values that are common in the execution environment) depends ...