How to emulate FDX-B cat tag (hex)

Hello everyone
I have a shy cat and need to register that cat to the pet-door.
As I cannot get hold of that cat, I cannot read it’s rfid tag and copy it to the cat door.
From the veterinary, I got the 15-digit id-number of the fdx-b tag. but the flipper wats it in hex.
Anyone has an idea how to convert that 15-digit id-number to the 22-digit hex?

1 Like

Good question, unfortunately I’ve paused my research at this topic. See: Animal tag “Bayer Animal Coder” issue - #10 by LupusE

I would search the source code of flipper as next step, for a better understanding.

I don’t see the pattern. None of the Hex seems to match my tag when I convert it to decimal. I did notice that editing the first part of the hex gave me errors. Editing the end didn’t seem to change the number on mine. Sadly I’ve been very busy without much time to tinker.

Here is, how the Flipper will decode FDX-B: flipperzero-firmware/protocol_fdx_b.c at dev · flipperdevices/flipperzero-firmware · GitHub

I’ve already read of the manchester encoding, but I am not familiar with this.

The 15 digits should already contain the Country Code. Sometimes the Number is just a string of digits, sometimes there is a dash, f.ex. 276-098nnnnnnn96. The first part is the country code
And than there is some CRC and parity calculation.

Interesting is the Comment at line 109 to 142.
I was not aware that T: is for the temperature.

The flipper shows a Hex Value above in the screen, I have not found this printf() so far, but I am reading on my phone screen in the highway. I will wait until home, to go through in a IDE.

Edit: Typo

That’s interesting. I may have to find one with a temperature sensor to play with.

I am afraid this is
a. a placeholder for future use
b. for another application

Since the RFID tag got its energy from the readers antenna, I can’t imagine it is enough to power an active sensor.

1 Like

I don’t know how much energy a temperature sensor uses so you may be right. There’s a smart padlock powered by NFC but I suspect NFC can inject more power then 125kHz RFID. On the padlock they harvest the energy into a capacitor that can actuate the lock.

EDIT: Found one that claims to have temperature. I don’t think there is much utility in it but I’m really just interested in the technology.

As far as I see now, the first 12 digits of the hex code are that animal identification number. and the first number in hex is somehow the last in dec.
The last 10 hex digits are always the same on those chips I’ve seen so far: 00 01 00 00 10.
There inside you have the “Animal: yes” and probably also the temperature (then, the 00 probably change)

I’m still trying to figure out, how they code the ID into that hex.
The “-” or the space after the country code is just to help reading. I haven’t seen it in the code yet.

1 Like

That was the last 10 digits of mine until I change it to 00 01 00 00 30. I saw no difference in the tags details after changing them though.

@Chrigu I figured it out after looking through the source code.

Since I was looking for the same thing as you and came up with nothing I wrote a couple python scripts to do what you are asking for as well as the reverse.

# convert Animal ID to hex data:

# take input from user
animal_id = int(input("Enter the 15 digit animal id: "))

# extract the first 10 digits and the next 38 digits from the combined decimal
last_10_decimal = int(str(animal_id)[:3])
first_38_decimal = int(str(animal_id)[3:])

# convert the decimal numbers to reversed binary
last_10_bits_reversed = bin(last_10_decimal)[2:].zfill(10)[::-1]
first_38_bits_reversed = bin(first_38_decimal)[2:].zfill(38)[::-1]

# concatenate the two binary strings and convert to hexadecimal
binary_num = first_38_bits_reversed + last_10_bits_reversed
hex_num = hex(int(binary_num, 2))[2:].zfill(12)

# add 0001000010 to the end of the 12 digit hex output to get a 22 digit hex output
hex_data = hex_num + "0001000010"

# output the original hexadecimal number
print("Original 22 digits of hex data [FDX-B]: ", hex_data)
# convert 22 digit hex data [FDX-B] to 15 digit base 10 animal id:

# take input from user
hex_data = input("Enter 22 digits of hex data [FDX-B]: ")

# extract the first 12 digits of hex data
hex_num = hex_data[:12]

# convert hexadecimal to binary and pad with leading zeros to get 48 bits
binary_num = bin(int(hex_num, 16))[2:].zfill(48)

# split the binary number into two sections
first_38_bits = binary_num[:38]
last_10_bits = binary_num[38:]

# reverse the two sections of binary
first_38_bits_reversed = first_38_bits[::-1]
last_10_bits_reversed = last_10_bits[::-1]

# convert the binary numbers to decimal
first_38_decimal = int(first_38_bits_reversed, 2)
last_10_decimal = int(last_10_bits_reversed, 2)

# combine the two decimal numbers
animal_id = int(str(last_10_decimal)[:3] + str(first_38_decimal)[:12])

# output the animal id
print("Animal ID: ", animal_id)

Very nice! I wonder if there are any other applications for this. It might be interesting to encode a telephone number directly into the tag. Question is would people recognize it’s a telephone number? I suppose you could try registering the telephone number as the tag ID in case someone didn’t recognize it.

It’s crazy how many people get these chips implanted in their animals but don’t register the chip or update the data. I think I heard 40% don’t register them meaning the owner can’t be located if the chip is the only identifier.

Great work!
While testing with all my scanned tags, I found a little issue.

In your # convert 22 digit hex data [FDX-B] to 15 digit base 10 animal id: script, the second part of the animal ID loosing the leading zero(s), if the animal tag is shorter than 12 digits

I fixed it with .zfill(12)

animal_id = int(str(last_10_decimal)[:3] + str(first_38_decimal)[:12])

animal_id = int(str(last_10_decimal)[:3] + (str(first_38_decimal)[:12]).zfill(12))

Based on the work of @cbytes, I started a small helper: FlipperMgmt/ at main · LupusE/FlipperMgmt · GitHub
Just execute it under Linux, the first question is a filename (enter for skip), the second is the ID in dec or hex.
The script

  1. cleans all :, - and " " character
  2. uses the math from the scripts above
  3. print out the cleaned (needed it for debugging, haven’t removed it) and the opposite value.
  4. write .rfid file, if filename was provided before.

Just copy the .rfid to the flipper and you can emulate your animal tag.

Can I convince you to put this in a GitHub repo? One nice place that can accommodate changes and updates.