这是我的代码:
<?php
$e = 'eyJpdiI6IkpVS2E3c1gxOGp0N3ZudERxb0hFemc9PSIsInZhbHVlIjoiM3MrNjkrWlNjb3lRYitxMGVPVVRPUT09IiwibWFjIjoiYTZhOWRjZjM2YTlkODc3ZDRjYjU5ODAxMmE3MGI3ZDE1ZDY5NjQzM2FmNjBkNDY5MDM1Mzg5ZTlkNDVjYjBiZSJ9';
$key = str_repeat('a', 32);
$payload = (array) json_decode(base64_decode($e));
$payload = array_map('base64_decode', $payload);
$p = openssl_decrypt(
$payload['value'],
'AES-256-CBC',
$key,
OPENSSL_ZERO_PADDING,
$payload['iv']
);
echo openssl_error_string() . "\n";
var_dump($p);
$payload['value']
和$payload['iv']
一样长16个字节。 AES的块大小也是16个字节,所以我不明白为什么会收到“ 数据不是块长度的倍数”错误...