问题描述
我需要找到一个解决方案来写MIFARE经典1K的标签与自定义键。我无法写出来,我曾尝试与每一个选项但遗憾的是所有的时间我得到的错误IOException异常:的Transceive失败。
I need to find a solution to write Mifare Classic 1 K Tag with Custom Key. I am unable to write it, I have tried with every option but unfortunately all the time I get the error "IOException: Transceive Failed".
下面是我的code片断:
Below is my code snippet:
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();
}
请帮我在这方面。我需要写MIFARE经典1K的标签用我自己的键。
Please help me in this regard. I need to write Mifare Classic 1 K Tag with my own key.
推荐答案
您验证到部门4,然后尝试写入块3块3的0扇区,所以这总是会失败。尝试验证扇区0来代替。
You authenticate to sector 4 and then you try to write to block 3. Block 3 is in sector 0, so this will always fail. Try authenticating to sector 0 instead.
BTW:请,不写随机数据到一个扇区尾(如3座)。它可能会锁定该部门没有办法恢复。
BTW: Please, don't write random data to a sector trailer (such as block 3). It will likely lock up the sector with no way to recover.
这篇关于如何写MifareClassic与自定义键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!