When calling the function openssl_encrypt
, it is always returned false. When I check the openssl_error_string
function, I get the following error:
error: 0906D06C: PEM routines: PEM_read_bio: no start line
The code I'm testing is this:
$data = 'Olá, Wallace!';
$encryption_key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC'));
$encrypted = openssl_encrypt($data, 'AES-256-CBC', $encryption_key, 0, $iv);
if (false === $encrypted) {
var_dump(openssl_error_string());
exit;
}
Why is this error generated?
I'm doing these tests trying to find a solution to this question: