fob key conversion

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
prussia
 
Posts: 27
Joined: Mon Jan 21, 2013 8:07 pm

fob key conversion

Post by prussia »

I have a rather idiotic newbie question.

I'm getting a fobkey read from an rfid reader i got a while back. It's coming in as ASCII hex i believe and on the pi using python i'd like to convert it to the actual key that is written on the fob.

so from
"0C0032667C24" to 0003303036 which is written the fob.

I feel like an idiot but i've tried in ipython everything to convert the ASCII/hex to that digit and nada.

Also i think the last two ASCII characters are checksum keys it's a 125khz rfid reader which doesn't seem to be sold on adafruit anymore though..

so i think checksum is 24

any help much appreciated for python help.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: fob key conversion

Post by adafruit_support_rick »

"0C0032667C24" is hex. Not sure what the 0c is, but I'll guess it's the total length of the string. 24 does appear to be some sort of checksum. So that leaves you with 0032667C hex, which is ...wait for it... 3303036 decimal!

User avatar
prussia
 
Posts: 27
Joined: Mon Jan 21, 2013 8:07 pm

Re: fob key conversion

Post by prussia »

Hi,
hmm thanks for the reply but I sort of stated all that in my post already? I was trying to get help with the python part but I think I figured it out after my post. All but how to use checksum to test

Code: Select all

fob_decimal = int(fob[2:10],16)
str(fob_decimal)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: fob key conversion

Post by adafruit_support_rick »

Sorry. I misunderstood the question.

The checksum looks like the accumulated XOR of the message bytes, including the 0C. At least, 0C ^ 00 ^ 32 ^ 66 ^ 7C is 24.

User avatar
prussia
 
Posts: 27
Joined: Mon Jan 21, 2013 8:07 pm

Re: fob key conversion

Post by prussia »

he he,
No problem. so i'm trying to write something in ipython to test the xor but i have no idea how i'd convert the fob string. add the 0x then XOR. seems in python I have to run:

Code: Select all

hex(0x0C ^ 0x00 ^ 0x32 ^ 0x66 ^ 0x7C)
to get 0x24 out (checksum) but not sure how to compose the above. nudge, hint or sample code would be nice :)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: fob key conversion

Post by adafruit_support_rick »

I'm definitely not the guy to ask about python, but I think you'd do something like

Code: Select all

check = int(fob[0:1],16) ^ int(fob[2:3],16) ^ int(fob[4:5],16) ^ int(fob[6:7],16) ^ int(fob[8:9],16) ^ int(fob[10:11],16)
That includes the checksum in the calculation, so the result should always be zero if you have a valid string.

Of course, you might want to code this up as a loop, if your strings can change in length.

User avatar
prussia
 
Posts: 27
Joined: Mon Jan 21, 2013 8:07 pm

Re: fob key conversion

Post by prussia »

hmm,
yeah I tried that but seems i need the 0x part too. not sure.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”