I searched for how to use openssl_encrypt
correctly, and found several stackoverflow questions and answers. However, I'm afraid I just can't get it to work.
My current code looks like this:
$encryption_key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(32);
$encrypted = openssl_encrypt($data, 'AES-256-CTR', $encryption_key, 0, $iv);
$error = openssl_error_string();
var_dump($encrypted, $error);
The var_dump
just gives me bool(false) bool(false)
. It doesn't work and I don't get any error.
Anyone can help me?
EDIT: I don't know what exactly the problem was, but apparently using AES-256-CTR did not work on the system. Using AES-256-CBC with above code works just fine...