How to change Keys A/B in Mifare Classic ?

Forum / MIFARE and NFC Reader IC`s / How to change Keys A/B in Mifare Classic ?

  • 9. March 2020 at 9:16
    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

    Re: How to change Keys A/B in Mifare Classic ?

    9. March 2020 at 9:17
    This post was already replied.

    The TapLinx team
    + 1  |  - 0

    Re: How to change Keys A/B in Mifare Classic ?

    1. April 2020 at 11:28
    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

    Re: How to change Keys A/B in Mifare Classic ?

    1. April 2020 at 12:07
    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

    Re: How to change Keys A/B in Mifare Classic ?

    21. April 2020 at 13:08
    Thanks sir, I also needed the answer
    + 0  |  - 1

    Re: How to change Keys A/B in Mifare Classic ?

    29. April 2020 at 17:51
    Thanks for the answer.
    + 0  |  - 0
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.