コード例 #1
0
        public MiFareClassicSmartCard(string pin, string cardId, MiFareCard connection, int sector)
        {
            if (pin == null) throw new ArgumentNullException("pin");
            if (cardId == null) throw new ArgumentNullException("cardId");
            if (connection == null) throw new ArgumentNullException("connection");

            // add the key to the conection
            var userKey = PinToKeyBytes(pin, cardId);
            connection.AddOrUpdateSectorKeySet(new SectorKeySet
            {
                KeyType = KeyType.KeyA,
                Sector = sector,
                Key = userKey
            });

            this.connection = connection;
            this.sector = sector;
            CardId = cardId;
        }
コード例 #2
0
        public MiFareClassicSmartCard(byte[] masterKey, string cardId, MiFareCard connection, int sector)
        {
            if (masterKey == null) throw new ArgumentNullException("masterKey");
            if (cardId == null) throw new ArgumentNullException("cardId");
            if (connection == null) throw new ArgumentNullException("connection");
            if(masterKey.Length != 6)
                throw new ArgumentOutOfRangeException("masterKey", "Key must be exactly 6 bytes");

            connection.AddOrUpdateSectorKeySet(new SectorKeySet
            {
                KeyType = KeyType.KeyB,
                Sector = sector,
                Key = masterKey
            });


            CardId = cardId;
            this.masterKey = masterKey;
            this.connection = connection;
            this.sector = sector;
        }