title: Securring stored password
body: <p>Actually I have a database that stores customer sensitive informations.
  I'm using something like that to encrypt that data:</p>
  
  <pre><code>$algo  = 'AES-256-CTR';
  $key ='password md5 from bdd'
  $iv   = substr(hash('sha256',$email),0,openssl_cipher_iv_length($algo));
  
  $data = base64_encode($data);
  $data = openssl_encrypt($data,$algo,$key,OPENSSL_RAW_DATA,$iv);
  </code></pre>
  
  <p>As you see I'm using the customer's email to create the iv and his password md5 for the key.
  So if someone hack my bdd he can decrypt the sensitive data.
  Is there a better way to do, knowing that my php script needs to be able to decrypt the data for use </p>
  
  <p>My ideas:</p>
  
  <p>-Use a executable on the server that create/modify the password and/or the iv and does the decryption and that the php script calls for that.</p>
  
  <p>-Use a second server that stores the passwords and that the php script needs to call for decryption.</p>