来自一个 mifare 标签的不同代码
Different codes from one mifare tag
我有两个 reader:
- mf7 (wiegand26)
- 桌面 USB reader (z2usb)
他们从标签发送不同的代码
(韦根 - USB):
13711284 - 6ECBD718
14056036 - CEA4D818
13409492 - 9E5BD718
如何转换?
有两个操作:NOT和反转位:)
public static Int32 CARD_CODE_LENGTH = 5;
static void Main(string[] args)
{
if (args.Length == 0) return;
String value = args[0];
if (value.Length < CARD_CODE_LENGTH)
throw new ArgumentException();
String cardCode = value.Substring(value.Length - CARD_CODE_LENGTH, CARD_CODE_LENGTH);
String facilityCode = value.Substring(0, value.Length - cardCode.Length);
Byte facility = ReverseWithLookupTable((Byte)(~Byte.Parse(facilityCode)));
UInt16 card = (UInt16)(~UInt16.Parse(cardCode));
Byte[] result = new Byte[2];
var temp = BitConverter.GetBytes(card);
for (var i = 0; i < temp.Length; result[i] = ReverseWithLookupTable(temp[i++]));
Console.WriteLine("{0}{1}{2}", facility.ToString("X2"), result[1].ToString("X2"), result[0].ToString("X2"));
Console.Read();
}
我有两个 reader:
- mf7 (wiegand26)
- 桌面 USB reader (z2usb)
他们从标签发送不同的代码 (韦根 - USB):
13711284 - 6ECBD718
14056036 - CEA4D818
13409492 - 9E5BD718
如何转换?
有两个操作:NOT和反转位:)
public static Int32 CARD_CODE_LENGTH = 5;
static void Main(string[] args)
{
if (args.Length == 0) return;
String value = args[0];
if (value.Length < CARD_CODE_LENGTH)
throw new ArgumentException();
String cardCode = value.Substring(value.Length - CARD_CODE_LENGTH, CARD_CODE_LENGTH);
String facilityCode = value.Substring(0, value.Length - cardCode.Length);
Byte facility = ReverseWithLookupTable((Byte)(~Byte.Parse(facilityCode)));
UInt16 card = (UInt16)(~UInt16.Parse(cardCode));
Byte[] result = new Byte[2];
var temp = BitConverter.GetBytes(card);
for (var i = 0; i < temp.Length; result[i] = ReverseWithLookupTable(temp[i++]));
Console.WriteLine("{0}{1}{2}", facility.ToString("X2"), result[1].ToString("X2"), result[0].ToString("X2"));
Console.Read();
}