【发布时间】:2023-03-08 03:01:01
【问题描述】:
我正在构建一个 iPhone 应用程序,它获取一个加密字符串并将其发送到后端。
在 PHP 中,我像这样加密字符串:
$encrypt_method = "AES-256-CBC";
$secret_key = 'This is my secret key';
$secret_iv = 'This is my secret iv';
// hash
$key = hash('sha256', $secret_key);
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
}
在 Objective C 中我如何做同样的事情
【问题讨论】:
-
我认为这是用于解密 AES 256 CBC,而不是加密