Using attr_encrypted with Rails 5.2 credentials master key
A short tutorial on how to use attr_encrypted with the same key as Rails credentials- Nov 20, 2018
- 1 min read
- #guides
- #ruby
- #rails
Warning
This post was written more than 5 years ago, and its contents may be out of date
Today’s another short tutorial is about using encryption key from Rails 5.2 credentials to encrypt/decrypt fields with attr_encrypted.
This way you can encrypt your database fields in Rails 5.2 without using separate keys for the fields and for the credentials:
attr_encrypted :super_secret_token, key: Rails.application.credentials.keyAaaaand… that’s it ¯\_(ツ)_/¯
Comments