title: How to generate encryption key for use with attr_encrypted
body: <p>I'm considering using the <a href="https://github.com/shuber/attr_encrypted" rel="noreferrer">attr_encrypted</a> gem for field-level encryption in a Rails app. How do I generate an encryption key for use with this gem?</p>
  
  <p>Update:</p>
  
  <p>The documentation for <a href="https://github.com/shuber/encryptor" rel="noreferrer">Encryptor</a>, which is the underlying encryption used by attr_encrypted, states the following (under Usage | Basic):</p>
  
  <pre><code>secret_key = Digest::SHA256.hexdigest('a secret key')
  encrypted_value = Encryptor.encrypt('some string to encrypt', :key =&gt; secret_key)
  </code></pre>
  
  <p>I would guess that <code>a secret key</code> can be any arbitrary-length random string and the call to <code>hexdigest</code> will compute an appropriate fixed-length string from it. Is this the recommended way to do it?</p>