public void Authenticate(byte block, MifareClassicKey key, MifareClassicKeyType keyType) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (!key.IsValid()) { throw new ArgumentException("Key is not valid", nameof(key)); } int ret; GCHandle h = GCHandle.Alloc(key.Value, GCHandleType.Pinned); try { ret = NativeMethods.mifare_classic_authenticate(this.m_tag.Handle, block, h.AddrOfPinnedObject(), keyType); } finally { h.Free(); } if (ret < 0) { throw new Exception("Authentication error: " + this.m_tag.LastError()); } }
public static extern int mifare_classic_authenticate(IntPtr tag, byte block, IntPtr key, MifareClassicKeyType keyType);