How to generate cryptographic key in the form of a binary string 16 bytes long in PHP
<p>I am trying to store a string in encrypted form in mysql DB, so looking for two way encryption, I found a guide about <a href="http://thefsb.tumblr.com/post/110749271235/using-opensslendecrypt-in-php-instead-of" rel="nofollow">openssl_encrypt / openssl_decrypt</a></p>

<pre><code>$ciphertext = openssl_encrypt($plaintext,  'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
$plaintext  = openssl_decrypt($ciphertext, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
</code></pre>

<p>That guide doesn't explain how to generate cryptographic key in the form of a binary string 16 bytes long for <code>$key</code> and crypto-secure random binary string 16 bytes long for <code>$iv</code>.</p>

<p>Any help would be appreciated.</p>