Esempio n. 1
0
        private static byte[] PrepareData(CardInitRequest req)
        {
            List <byte> buffer = new List <byte>();

            buffer.AddRange(Encoding.ASCII.GetBytes("RFT"));                    // 3
            buffer.AddRange(req.SN);                                            // 4
            buffer.AddRange(Encoding.ASCII.GetBytes(req.UserId));               // 6
            buffer.AddRange(BitConverter.GetBytes(req.Sector));                 // 2
            buffer.Add((byte)0x00);                                             // 1

            logger.Debug("Prepare Key data : " + BitConverter.ToString(buffer.ToArray()));
            return(buffer.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Key : 'RFT'(3) + sn(4) + userId(6) + sectorType + '00'
        /// </summary>
        public static CardInitResponse ComputeKey(CardInitRequest req)
        {
            byte[] factor = PrepareData(req);

            CardInitResponse response = new CardInitResponse()
            {
                Sector      = req.Sector,
                ReadableKey = BitConverter.ToString(ComputeReadableKey(factor)),
                WritableKey = BitConverter.ToString(ComputeWritableKey(factor))
            };

            return(response);
        }