如何使用自定义键编写MifareClassic

Man*_*ani 2 android nfc mifare

我需要找到一个解决方案,用自定义密钥编写Mifare Classic 1 K标签.我无法写它,我已经尝试了所有选项但不幸的是我一直得到错误"IOException:Transceive Failed".

以下是我的代码片段:

byte custom_key[]={
  (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff
};

// 16 bytes of Data. Otherwise it was throwing IllegalArgumentException .
byte[] data="Hello world of N".getBytes();
getMfc().connect();

if(getMfc().authenticateSectorWithKeyA(4, custom_key)) {
  getMfc().writeBlock(3, data); // Here I receive IOException all the time.
} else {
  getMfc().close();
}
Run Code Online (Sandbox Code Playgroud)

请帮助我这方面.我需要用自己的密钥编写Mifare Classic 1 K标签.

NFC*_*guy 6

您对扇区4进行了身份验证,然后尝试写入块3.块3位于扇区0中,因此总是会失败.尝试对扇区0进行身份验证.

顺便说一句:请不要将随机数据写入扇区预告片(例如块3).它可能会锁定该部门而无法恢复.