注释修改密码
密码现识别为ffffffffffff和010203040506
| | |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | } |
| | | if (cleanCard != null) { |
| | | NFCWriteHelper.getInstence(intent).changePasword(1); |
| | | setClean(intent, cleanCard); |
| | | } |
| | | if (manageCard != null) { |
| | |
| | | */ |
| | | public class BaseNFCHelper { |
| | | /** |
| | | * 默认密码(白卡密码) |
| | | * 默认密码(白卡密码)ffffffffffff |
| | | */ |
| | | public byte[] defauleKey; |
| | | |
| | |
| | | * 公司密码 |
| | | */ |
| | | public byte[] companyKey; |
| | | |
| | | //密码a区 |
| | | String companyKeyA; |
| | | //密码B区 |
| | | String companyKeyB; |
| | | |
| | | |
| | | public BaseNFCHelper() { |
| | | // 解密字符串 |
| | | try { |
| | | //初始密码 |
| | | byte[] encryptedBytes = Base64.decode("orDiGzvueQqPpU+VQ3NEzQ==", Base64.DEFAULT); |
| | | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
| | | byte[] encodedKey = {-117, -104, -100, 84, 111, -102, -29, -21, 72, -82, -105, 123, 77, 79, 17, -55, -102, -28, 50, 23, 67, 98, 0, -96, -10, -48, -60, 81, 113, 80, -32, -26}; |
| | |
| | | byte[] decryptedBytes = cipher.doFinal(encryptedBytes); |
| | | String decryptedText = new String(decryptedBytes, StandardCharsets.UTF_8); |
| | | defauleKey = HexUtil.hexToByteArray(decryptedText); |
| | | |
| | | byte[] encryptedBytes2 = Base64.decode("aYC9feYEOFOQHuzflLIXSw==", Base64.DEFAULT); |
| | | //初始密码 |
| | | // byte[] encryptedBytes2 = Base64.decode("aYC9feYEOFOQHuzflLIXSw==", Base64.DEFAULT); |
| | | byte[] encryptedBytes2 = Base64.decode("qeg4DUWf0ni9JfRWtD2krA==", Base64.DEFAULT); |
| | | byte[] decryptedBytes2 = cipher.doFinal(encryptedBytes2); |
| | | companyKeyA = new String(decryptedBytes2, StandardCharsets.UTF_8); |
| | | companyKey = HexUtil.hexToByteArray(companyKeyA); |
| | | |
| | | //修改后的密码 |
| | | byte[] encryptedBytes3 = Base64.decode("n+SSZFb4DHsreVav/Z5ftg==", Base64.DEFAULT); |
| | | byte[] decryptedBytes3 = cipher.doFinal(encryptedBytes3); |
| | | companyKeyB = new String(decryptedBytes3, StandardCharsets.UTF_8); |
| | | |
| | | |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (NoSuchPaddingException e) { |
| | |
| | | public boolean writeData(byte[] str, int a, int b) { |
| | | Log.i("NFCWreatActivity", "writeData: a=" + a + " b=" + b); |
| | | //写卡时修改所有密码 |
| | | changePasword(a); |
| | | // changePasword(a); |
| | | if (str.length <= 16) { |
| | | try { |
| | | MifareClassic mfc = MifareClassic.get(tag); |
| | |
| | | |
| | | int count = mfc.getSectorCount(); |
| | | boolean isOpen = mfc.authenticateSectorWithKeyA(a, defauleKey); |
| | | |
| | | //验证是否是默认密码,当默认密码时修改密码 |
| | | if (isOpen) { |
| | | //将密码转换为keyA |
| | |
| | | # For customization when using a Version Control System, please read the |
| | | # header note. |
| | | #Sat Nov 11 20:12:34 CST 2023 |
| | | sdk.dir=D\:\\AndroidStudio\\sdk |
| | | sdk.dir=D\:\\sdk |