3、将AUTHLIM(第E4页,字节0,位2-0)设置为最大失败密码验证尝试次数(将此值设置为0将允许无限次数的PWD_AUTH尝试).将PROT(第E4页,字节0,位7)设置为所需的值(0 =仅在写访问时需要PWD_AUTH,1 =读和写访问需要PWD_AUTH).
let response = sendCommand([0x30,E4]); //读取E4页数据
let response = readResponseE4.result;
let prot = false; // false 为只加密写 true为读写都加密
let authlim = 0;
let writeResponse = sendCommand([0xA2, E4, ((response[0] & 0x078) | (prot ? 0x080 : 0x000) | (authlim & 0x007)), response[1], response[2], response[3]]);
4、将AUTH0(第E3页,字节3)设置为应该要求密码验证的第一页.
let readResponseE3 = sendCommand([0x30, 0xE3]); //读取E3页数据
let writeResponseT = sendCommand([0xA2, index - 2, readResponseE3.result[0], readResponseE3.result[1], readResponseE3.result[2], (0 & 0x0ff)]); //0为密码要保护的开始位置。
三、验证密码(0x1B为验证命令)
sendCommand([0x1B, pass[0], pass[1], pass[2], pass[3]]); //验证通过会返回pack值,还需要与本地验证pack是否一致
四、删除密码
首先需要验证密码,然后只需将AUTH0(即配置起始页)设置为0x0ff即可。
let readResponse = sendCommand([0x30, E3]);
let deleteStatu = sendCommand([0xA2, E3, response[0], response[1], response[2], (0x0ff & 0x0ff)]);
五、ios原生方法
需要将传入的byte数组转成data类型。
- (void)sendMiFareCommand:(NSData *)command completionHandler:(void(^)(NSData *response, NSError * _Nullable error))completionHandler API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
相关参考资料