有没有比在MIFARE Classic卡上写全零更好的方法了?
这是我当前代码的示例:
for (i in 0 until sectorCount) {
if (!authenticateSectorWithKeyA(i, key) && !authenticateSectorWithKeyA(i, MifareClassic.KEY_DEFAULT)) {
break
}
val idx = sectorToBlock(i)
for (j in 0 until getBlockCountInSector(i)) {
val index = idx + j
when (index) {
0 -> cardId = getCardId(readBlock(idx + j))
1 -> {} //Todo: Write specail data
4 -> {} //Todo: Write specail data
5 -> {} //Todo: Write specail data
else -> {
if ((index + 1) % 4 != 0) {
writeBlock(index, ByteArray(16).apply { fill(0.toByte()) })
}
}
}
}
}