左晓为主开发手持机充值管理机
zuoxiao
2023-11-14 5a843ba11b991722f8f2af386f0e546e2769f7c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.dayu.recharge.tools;
 
import android.util.Base64;
 
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
 
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
 
/**
 * Copyright (C), 2023,
 * Author: zuo
 * Date: 2023-11-09 11:52
 * Description:
 */
public class BaseNFCHelper {
    /**
     * 默认密码
     */
    public byte[] bytes;
 
    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};
            cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(encodedKey, "AES"));
            byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
            String decryptedText = new String(decryptedBytes, StandardCharsets.UTF_8);
            bytes = HexUtil.hexToByteArray(decryptedText);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (NoSuchPaddingException e) {
            throw new RuntimeException(e);
        } catch (InvalidKeyException e) {
            throw new RuntimeException(e);
        } catch (BadPaddingException e) {
            throw new RuntimeException(e);
        } catch (IllegalBlockSizeException e) {
            throw new RuntimeException(e);
        }
    }
}