同一张卡的坐标标识是由两个不同的读卡器读 [英] Coordinate Id of same card that is read by two different card readers

查看:451
本文介绍了同一张卡的坐标标识是由两个不同的读卡器读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个软件的一部分,卡是由读卡器读取和被分配给一个用户。而在该软件的其他部分,由同一个读卡器终端,用户卡被读取并获取由卡的序列号等,从数据库数据。

In a part of a software, card is read by a card reader and is allocated to an user. And in other part of this software, in a terminal by same card reader, the user card is read and fetch data from database by card serial number and etc.

在一个这个软件的新零件,有一个新的读卡器一个新的终端。卡从该卡读取器读取,并且可以从数据库等数据

In a new part of this software, there are a new terminal with a new card reader. card is read from this card reader and fetch data from database and etc.

所以,现在的问题是,由这两个读卡器读取同一张卡是不同的类型。第一设备退卡ID作为一个十六进制字符串,如:

So, now the problem is that a same card that is read by this two card readers are different in type. The first device return card id as a hexadecimal string, like this:

2E 6F 27 3F

这十六进制字符串被转换为十进制和被存储在数据库中。例如,上述十六进制字符串转换为这个整数:

This hexadecimal string is converted to decimal and is stored in the database. For example, the above hexadecimal string is converted to this integer:

779036479

现在,当第二个读卡器读出同样的卡,卡ID是字节该卡的数组,像这样:

Now, when second card reader read this same card, the card id is an array of bytes, like this for that card:

byte0: 49
byte1: 48
byte2: 53
byte3: 57
byte4: 53
byte5: 52
byte6: 56
byte7: 57
byte8: 55
byte9: 52

如何协调同一张卡的相互这两序列号?换句话说,我想这个字节数组转换成相应的十六进制代码,从而使这个十六进制代码是卡第一设备是返回的序列号?

How can I coordinate this two serial number of same card with each other? In other words, I want to convert this array of bytes to corresponding hex code, so that this hex code is the serial number of that card that first device is return?

该卡片为Mifare。

The card is Mifare.

推荐答案

答案是第二个读者返回ASCII编码小数。您的号码是 1059548974 。这个数字,编码为十六进制数为 3F276F2E 如果你使用大端编码。如果您使用的Little Endian编码,那么你将获得 2E6F273F 这应该是你熟悉的

The answer is that the second reader is returning ASCII encoded decimals. Your number is 1059548974. This number, encoded into hexadecimals is 3F276F2E if you use Big Endian encoding. If you use Little Endian encoding then you will get 2E6F273F which should be familiar to you.

这样:


  1. 解码返回的字节数组为ASCII,检索字符串1059548974

  2. 该字符串使用转换为整数 Convert.ToUInt32(STR);

  3. 扭转字节整数

大概扭转字节的最好办法就是这段代码:

Probably the best way to reverse the bytes is this piece of code:

public static UInt32 ReverseBytes(UInt32 value)
{
  return (value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 |
         (value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;
}

这篇关于同一张卡的坐标标识是由两个不同的读卡器读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆