I'm encrpyting my web application file download system with openssl (openssl_encrypt and openssl_decrypt) and I want to generate random password and IV for that. Encryption method will be AES-256-CBC. I'm newbie with cryptography and found very little information about the issue.
function encryptString($str) {
$encryptionMethod = "AES-256-CBC";
$secretHash = "gererated random secret openssl key here";
$encryptedStr = openssl_encrypt($str, $encryptionMethod, $secretHash, false, "generated random IV here");
return $encryptedStr;
}
I tried openssl_pkey_new(); but it returned me boolean false. Is this the right way?
I got the tip from here: Two-way encryption in PHP
as test environment im running WAMP localhost.