在我的后端,他们使用带有 16 字节 key 的 AES 算法和这段代码创建了加密消息
key :h7Ui63Mzqj61G87j
public static String encrypt(String data, byte[] secretKey) throws Exception {
Key key = generateKey(secretKey);
Cipher c = Cipher.getInstance(ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(data.getBytes());
String encryptedValue = new BASE64Encoder().encode(encVal);
if (logger.isDebugEnabled()) {
logger.debug(String.format("DataToEncrypt: %s, encryptedValue: %s", data, encryptedValue));
}
return encryptedValue;
}
但我无法使用 AES 算法用相同的 key 解密消息。
最佳答案
关于ios - 使用 Objective-C 的 AES Java 加密 16 字节 key 解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41951715/