user556615
user556615

Reputation: 31

How Can i read mifare classic 1k Card by Nexus s

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")

Upvotes: 3

Views: 9473

Answers (2)

sam
sam

Reputation: 1

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 of authenticateSectorWithKeyB().

Upvotes: 0

Krzysztof Dubrowski
Krzysztof Dubrowski

Reputation: 148

You won't be able to readBlock() or writeBlock() after using authenticateSectorWithKeyB(). 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() and writeBlock() will throw an exception. You will have to perform reading of the tag using KeyA authentication.

Upvotes: 1

Related Questions