在我的后端侧他们创造使用AES算法加密的消息与这一段代码AES的Java加密16字节与目标C密钥解密
键16字节的密钥: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算法解密消息
我提到很多链接和博客没有帮助我,任何人都可以请帮我解决这个问题。
您的钥匙长16个字符。你如何将它转换成32字节? – Codo
好吧,现在我们有16 *个字符*和16 *字节*。你如何从字符转换为字节? – Codo
并且请显示迄今为止您所拥有的Objective-C代码。并告诉我们“我无法解密信息”的含义。不编译?它会崩溃吗?它会产生错误的输出吗?什么是输入,什么是预期的输出,什么是有效的输出? – Codo