this kind of encryption helps only in case when your database is stolen
if hacker gets access to Rails console or ENV['ENCRYPTION_KEY'], you’re hacked
you may want to use IV and salt for sensitive data
by using Marshal, our encrypted field can store instance of any class (Date, Time, whatever!)
Done! You can use EncryptedCoder in any model.
A quick demo:
Tweet the link
About the author
Kir Shatrov helps businesses to grow by scaling the infrastructure. He likes to write about software, scalability and interesting stories that he runs into at work. Follow him on Twitter to get the latest updates: @kirshatrov.