如何验证Mifare Plus Sl3卡以在不同/多个扇区/块上进行读写

时间:2019-09-12 12:28:37

标签: java android nfc mifare

我正在尝试在128位扇区或多个扇区上进行读写

我正在通过taplinx进行此操作,这使我既可以读写,又可以 但是我想要另一个领域。怎么办?

if (plusSL3.getCardDetails().securityLevel.equals("Security Level 3")) {
        try {

            /** ALL WORK RELATED TO MIFARE PLUS SL3 card. */
            plusSL3.authenticateFirst(0x4004, objKEY_AES128, pcdCap2In);
            //plusSL3.au(0x9000, objKEY_AES128, pcdCap2In);


            sendMessageToHandler("Authentication status: true", 'n');
        /* Do the following only if write checkbox is selected */

            String DATAMOBILE="arrrr22 Arjun Saini Rs. 5000 ";
            int integer =DATAMOBILE.length();

            StringBuilder s = new StringBuilder(200);
            s.append(DATAMOBILE);
            for (int j = 0; j < 48 - integer; j++) {
                s.append(" ");
            }
            DATAMOBILE = s.toString();



            byte[] bytesData = DATAMOBILE.getBytes();


            byte[] bytesEncData1 = encryptAESData(bytesData, bytesKey);
            bWriteAllowed=true;

       if (bWriteAllowed) {

                plusSL3.writeValue(IPlusSL3.WriteMode.Plain_ResponseMACed, 12, 999, (byte) 0x09);


                valueResult = plusSL3.readValue(IPlusSL3.ReadMode.Plain_ResponseMACed_CommandMACed, 12);
                sendMessageToHandler(
                        "Read Value From Block-9 :" + valueResult.getDataValue(),
                        'd');

                plusSL3.multiBlockWrite(IPlusSL3.WriteMode.Plain_ResponseMACed, (byte) 12, 3, bytesEncData1);

                sendMessageToHandler("Multiblock write is true:", 'n');
            }

            result = plusSL3.multiBlockRead(IPlusSL3.ReadMode.Plain_ResponseMACed_CommandMACed, 12, 3);
            byte[] bytesDecData = decryptAESData(result, bytesKey);

            String strdate = new String(bytesDecData);
            Toast.makeText(MainActivity.this,strdate,Toast.LENGTH_LONG).show();



            sendMessageToHandler(
                    "Multiblock read is :" + Utilities.dumpBytes(result), 'n');
            NxpLogUtils.save();
        } catch (Exception e) {
            Log.e("@@@ERROR",e.getMessage());
            showMessage(e.getMessage(), 'n');
            showMessage("Exception occurred... check LogCat", 't');
            e.printStackTrace();
        }
    } else {
        showMessage("No operations done since card is in secuirty level 0", 'n');
    }

0 个答案:

没有答案