https://open.feishu.cn/document/uYjL24iN/ugjMx4COyEjL4ITM
示例中没有 php 语言,看来 php 是真的不重视了,上次集成 google firebase 也是,官方没提供 php 支持。
if ($user) {
$aesKey = base64_decode($user->sessionKey);
$aesIV = base64_decode($iv);
$aesCipher = base64_decode($encryptedData);
$result = openssl_decrypt( $aesCipher, 'AES-128-CBC', $aesKey, 1, $aesIV );
info( json_encode($result) );
info( openssl_error_string() );
/*$user->update([
'avatarUrl' => $avatarUrl,
'nickName' => $nickName,
]);*/
}
报错
local.ERROR: openssl_decrypt(): IV passed is 24 bytes long which is longer than the 16 expected by selected cipher, truncating {"exception":"[object] (ErrorException(code: 0): openssl_decrypt(): IV passed is 24 bytes long which is longer than the 16 expected by selected cipher
1
rekulas 2022-07-08 09:58:34 +08:00
iv = 'f210af090c830cd5c47e67eeb4f52001';
错误很明显,iv 是 hex 你用 base64 解码那肯定错的 hex2bin |
2
laravel OP 让我改好了
``` $aesKey = hex2bin($user->sessionKey); $aesIV = hex2bin($iv); ``` 但是又报 error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length 这个应该好解决了 |