How can I securely generate a key suitable for hashing data with AES 256 using PHP?
I've tried Googling and found plenty of information about how to encrypt data using AES 256 using PHP, however all of these examples used existing pre-generated keys, wheras I need to generate the key in PHP.
The openssl-pkey-new() function is exactly what you are looking for.
As for the IV, you can look at How to securely generate an IV for AES CBC Encryption? which recommends using openssl-random-pseudo-bytes
But if you are really looking for a helpful page, Google "Implement AES in PHP" - as the first hit you will find http://www.movable-type.co.uk/scripts/aes-php.html which surely will teach you everything you need to know...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With