我如何读取 Nexus s 的 mifare classic 1k 卡
正在使用 NFC Android 编程,我想读取 Mifare Classic 卡。有人知道如何读取此类卡的扇区吗?
身份验证方法返回true,这意味着身份验证已完成。身份验证后,扇区应该准备好进行任何 IO 操作,但每当我使用 readBlock() 方法或 transceive() 方法时,我都会收到 IOException(“收发失败”) 异常。我找不到任何使用 Mifare Classic 的示例,所以我想知道是否可以使用此 API 读取 Mifare Classic。
我的代码是这样的 boolean success = m1tag.authenticateSectorWithKeyB(0,MifareClassic。KEY_DEFAULT) int索引 = m1tag.sectorToBlock(0) byte[] content = m1tag.readBlock(index)
success 是 true,但是当我从卡中读取内容时,抛出 IOException("transceive failed")
am working with NFC Android programming and I want to read Mifare Classic cards. Does anybody know how to read the sectors off such a card?
Authentication method returns true which means that authentication is done. After authentication, sector should be ready for any IO action but whenever i use readBlock() method or transceive() method, I get exception with IOException("transceive failed"). I can not find any example which uses the Mifare Classic, so i want to know if it is possible to read the Mifare Classic with this API or not.
My code like this boolean success = m1tag.authenticateSectorWithKeyB(0,MifareClassic。KEY_DEFAULT)
int index = m1tag.sectorToBlock(0)
byte[] content = m1tag.readBlock(index)
success is true,but when i read content from card,throw IOException("transceive failed")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
authenticateSectorWithKeyB()
后,您将无法进行readBlock()
或writeBlock()
。如果它是具有默认访问位的新标签,则对该标签的访问将被阻止。如果访问条件已更改,则
readBlock()
和writeBlock()
将引发异常。您必须使用 KeyA 身份验证来读取标签。You won't be able to
readBlock()
orwriteBlock()
after usingauthenticateSectorWithKeyB()
.If it is a new tag with default access bits access to the tag will be blocked. If the access conditions have be changed then
readBlock()
andwriteBlock()
will throw an exception. You will have to perform reading of the tag using KeyA authentication.您无法通过使用 keyB 进行身份验证来读取 mifare 卡的块。
要读取 Mifare 卡块,您必须使用密钥 A 进行验证,即使用
authenticateSectorWithKeyA()
而不是authenticateSectorWithKeyB()
。You can not read the Block of a mifare card by authonticating with keyB.
To read the block of Mifare card, you will have to aunthenticae with key A i.e. use
authenticateSectorWithKeyA()
instead ofauthenticateSectorWithKeyB()
.