· 9 years ago · Nov 01, 2016, 09:14 AM
1public class ChallengeResponseEncryptor {
2 private static byte[] mSharedSecretKeySdk = new byte[]{
3 (byte) 0xAF, (byte) 0x12, (byte) 0x5E, (byte) 0x00, (byte) 0xD2,
4 (byte) 0xF7, (byte) 0x11, (byte) 0xE4, (byte) 0x9E, (byte) 0x51, (byte) 0x00, (byte) 0x02, (byte) 0xA5,
5 (byte) 0xD5, (byte) 0xC5, (byte) 0x1A
6 };
7
8 public static byte[] encryptKey(byte[] deviceKey) {
9 try {
10 SecretKey aesKey = new SecretKeySpec(mSharedSecretKeySdk, "AES");
11 Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
12 cipher.init(Cipher.ENCRYPT_MODE, aesKey);
13 byte[] encrypted = cipher.doFinal(deviceKey);
14 return encrypted;
15 }
16 catch (GeneralSecurityException e) {
17 e.printStackTrace();
18 return null;
19 }
20 }
21}