title: Is there a way to get same encrypted hash value with some secret key?
body: <p>I want to encrypt sensitive data in an encrypted format and save it to db. But later I have to be able to decrypt with a secret key used to decrypt. Importantly, encryption must give always the same hash.</p>
  <pre><code>
  const algorithm = 'aes256';
  const iv = crypto.randomBytes(16).toString('hex').slice(0, 16);
  const key = crypto
    .createHash('sha256')
    .digest('base64')
    .substr(0, 32);
  
  const cipher = crypto.createCipheriv(algorithm, key, iv);
  const encrypted =
    cipher.update(String('tobeEncrypted'), 'utf8', 'hex') + cipher.final('hex');
  
  console.log(encrypted); 
  console.log(encrypted); 
  //e08f733a4dace8b22db763cbd2d0029e
  //90086251f083c33dd6aa017a2c6f35f4
  
  // How can I always get the same hash value?
  </code></pre>