java mifare_java – NTAG212 Mifare Ultralight与身份验证

本文主要介绍了如何在Java中通过NFC与NTAG212 Mifare Ultralight标签进行交互,特别是关于PWD_AUTH命令的正确使用方法。内容包括如何设置和验证密码,以及启用密码保护,以便进行安全的数据读写操作。
摘要由CSDN通过智能技术生成

我是NFC Android的新手,我已经坚持了几天试图通过身份验证获得NTAG212 Mifare Ultralight的第7页,我已经有了PWD和PACK来完成基于NTAG212文档的PWD_AUTH.

我这样做…

//assume password as array of bytes

//assume pack as array of bytes

try{

nfc.connect();

byte[] cmd1 = nfc.transceive(new byte[]{ (byte) 0x30, (byte) 0x00 }); //read the page 0 to make the NFC active

nfc.transceive(new byte[]{

(byte) 0x1B, //command for PWD_AUTH

pass[0],

pass[1],

pass[2],

pass[3]

});

byte[] cmd4 = nfc.transceive(new byte[]{ (byte) 0x30, (byte) 0x04 }); //read the page 4

}catch(TagLostException e){

e.printStackTrace();

}catch(IOException e){

e.printStachTrace();

}finally{

try{

nfc.close();

}catch(Exception e){

//display failed to close

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值