Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中java类的类似类';SecretKeySpec';_Ios - Fatal编程技术网

iOS中java类的类似类';SecretKeySpec';

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

我想从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', '/', '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$