Forum / MIFARE and NFC Reader IC`s / How to change Keys A/B in Mifare Classic ?
Tagged: MIFARE Classic, taplinxsdk
-
I want to change A/B Keys for default classic sector in Mifare Classic NFC.
I am using very basic code writing/reading and worked very well.
int blockTorw = Consts.DEFAULT_SECTOR_CLASSIC;
int sectorOfBlock = 0;
try {
//Call connect first is the Reader is not connected
if (!mifareClassic.getReader().isConnected()) {
mifareClassic.getReader().connect();
}
sectorOfBlock = mifareClassic.blockToSector(blockTorw);
mifareClassic.authenticateSectorWithKeyA(sectorOfBlock, default_ff_key);
if (is_write) {
/** write data to block **/
//int newerBalance = Integer.parseInt(olderBalance) + topupAmount;
int newerBalance = topupAmount;
byte[] balanceBytes = Utils.getChipBalanceBytes(newerBalance);
mifareClassic.writeBlock(blockTorw, balanceBytes);
ToastManager.showToast(getString(R.string.topup_successful));
updateBalanceTextView(String.valueOf(newerBalance));
is_write = false;
//topupAmount = 0;
}
} catch (Exception e) {
Log.e(TAG, "Classic tag error: " + e.getMessage());
}
I am using
implementation ('taplinx-android:nxpnfcandroidlib:1.5@aar'){
transitive = true
changing = true
}
+ 0 | - 0
This post was already replied.
The TapLinx team
+ 1 | - 0
Hey I also need answer how to change A/B Keys for default classic sector in Mifare Classic NFC. It would be great if anyone can help me. Thanks in advance
+ 1 | - 0
Hi Saimi,
To change a key you simply write the data to the sector trailer. But be careful! I recommend to read the block, change the six key bytes and write the block back. You should re-authenticate to the sector after changing the key bytes.
The TapLinx team
+ 1 | - 0
Thanks sir, I also needed the answer
+ 0 | - 1
Thanks for the answer.
+ 0 | - 0
-
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.