iOS中java类的类似类';SecretKeySpec';
我想从AES加密的字符集生成密钥 {'a'、'/'、'5'、'0'、'0'、'2'、'*'、'l'、'+'、'O'、'&'、'@'、'b'、'~'、'''.'美元'}iOS中java类的类似类';SecretKeySpec';,ios,Ios,我想从AES加密的字符集生成密钥 {'a'、'/'、'5'、'0'、'0'、'2'、'*'、'l'、'+'、'O'、'&'、'@'、'b'、'~'、'''.'美元'} in Java they are generating 'SecretKeySpec' like : private static final String ALGO = "AES"; private static final byte[] keyValue = new byte[] { 'a
in Java they are generating 'SecretKeySpec' like :
private static final String ALGO = "AES";
private static final byte[] keyValue =
new byte[] { 'a', '/', '5', '0', '0', '2', '*', 'l', '+', 'O', '&','@', 'b', '~', '_', '$' };
//Generate Secret Key
private static
generateKey() throws Exception {
SecretKeySpec key = new SecretKeySpec(keyValue, ALGO);
return key;
}
现在我需要在iOS中获得一个与Java相同的密钥,这样我的加密密码在这两种情况下都是相同的。每次运行代码时,给定字符集的键值都保持不变
unsigned char keyPtr[kCCKeySizeAES128] = { 'a', '/', '5', '0', '0', '2', '*', 'l', '+', 'O', '&','@', 'b', '~', '_', '$' };
然后我将其转换为字符串,并用作AES加密的密钥
NSString* encryptedKey = [NSString stringWithUTF8String:(char *)keyPtr];
这给了我字符串值a/5002*l+O&@b~\u$