openssl_decrypt расшифровывает aes-256-gcm
$ out = [];
// пример из // https://crypto.stackexchange.com// Proper-реализация-of…
$dataToEncrypt = 'Hello World';
// $cypherMethod = 'AES-256-GCM'; -> Warning: openssl_cipher_iv_length(): Unknown cipher algorithm
$cypherMethod = 'aes-256-gcm';
$key = random_bytes(32);
$iv = random_bytes(openssl_cipher_iv_length($cypherMethod));
$encryptedString = openssl_encrypt($dataToEncrypt, $cypherMethod, $key, $options=0, $iv, $tag);
$out['example1'] = openssl_decrypt($encryptedString, $cypherMethod, $key, $options=0, $iv, $tag);
// https://docs.onlinepayments.pt//webhooks/decryption-example // demo php <7.1
$key_from_configuration = "000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f";
$iv_from_http_header = "000000000000000000000000";
$auth_tag_from_http_header = "CE573FB7A41AB78E743180DC83FF09BD";
$http_body = "0A3471C72D9BE49A8520F79C66BBD9A12FF9";
$key = hex2bin($key_from_configuration);
$iv = hex2bin($iv_from_http_header);
$cipher_text = hex2bin($http_body . $auth_tag_from_http_header);
$out['example2'] = sodium_crypto_aead_aes256gcm_decrypt($cipher_text, NULL, $iv, $key);
// https://docs.onlinepayments.pt//webhooks/decryption-example // пример php >7.1
$key = hex2bin($key_from_configuration);
$iv = hex2bin($iv_from_http_header);
$auth_tag = hex2bin($auth_tag_from_http_header);
$cipher_text = hex2bin($http_body);
//
$out['example3'] = openssl_decrypt($cipher_text, "aes-256-gcm", $key, 0, $iv, $auth_tag);
var_dump($out);
array:3 [▼ "example1" => "Hello World" "example2" => "{"type":"PAYMENT"}" "example3" => false ]
Почему $out['example3'] - возвращает false, а не {"type":"PAYMENT"}, как в примере 2 - у него те же данные для расшифровки?