hi all,
I'm in develop system via Card Reader....and on thing I'm found problem is...
The HEX data that apper is twisted with my old application..

It's like this;-

0A 37 73 AF supposely be like this AF 73 37 0A

Can anyone help me? plz...:'(

Dani AI

Generated

Most likely this is a byte-order (endianness) mismatch between what the card reader sends and how your app or database expects the serial. described the output appearing "reversed" and 's question about what to do with the hex is exactly the right place to start: confirm whether the device is sending bytes LSB-first or MSB-first and normalize before comparison. See a short explanation of endianness here.

Practical steps:

  • Capture the raw data the reader returns (bytes, not a text conversion). Print the hex pairs exactly as received to validate ordering.
  • Remove any non-hex noise (CR/LF, CRC bytes, framing) before processing.
  • Convert the hex pairs to a byte array, reverse the array if needed, then convert back to the canonical hex string you store in the DB.
  • If possible, set the reader/SDK to output the preferred order so you do not have to fix it in code.

Example (WinForms/C#) to reverse byte order read from a TextBox:

string hex = textBox1.Text.Replace(" ", "");
int n = hex.Length;
byte[] bytes = new byte[n / 2];
for (int i = 0; i < bytes.Length; i++)
    bytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
Array.Reverse(bytes);
textBox1.Text = BitConverter.ToString(bytes).Replace("-", " ");

Notes and troubleshooting: check the reader manual/SDK for settings that control byte order or CRC inclusion. If reversing bytes doesn't match, verify whether bits or nibbles are being reversed (less common). Always store and compare a single canonical format in the DB so future readers or changes are easier to handle; use the device docs and Array.Reverse if you need to perform the transformation in code.

Recommended Answers

All 2 Replies

what you want to do with hex data ?

To compare with my database data..actually for serial ID .....i'm use serial id number as special key for link to Staff infomation...it's like A325E90 for Staf ID - 0223,Name :John.....so i use this hex data for reconise the userr....plz help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.