Encrypt data at rest in Ruby and Rails, with keys held outside your source code.
See the codeEncrypt data at rest in Ruby and Rails, with keys held outside your source code.
database.yml and other configuration files.Documentation: encryption.reidmorrison.com
Rails 7 added Active Record encryption. If everything you need to encrypt is an Active Record attribute, use that instead. It is built in, and it is maintained by the Rails team.
This gem covers what it does not: Mongoid fields, whole files and streams, standalone Ruby, passwords decrypted before Rails has finished booting, keys held in a cloud KMS, and rotating the key of a value that has to stay queryable. See Do you need it? for the full comparison.
gem "symmetric-encryption"
Generate a configuration file and a key for every environment:
symmetric-encryption --generate --app-name my_app
Encrypt an Active Record attribute. The column is a string, since the encrypted value is text:
class Person < ActiveRecord::Base
attribute :ssn, :encrypted
end
person = Person.create!(name: "Jack", ssn: "123456789")
person.ssn
# => "123456789"
Continue with the Guide, which builds up from here one step at a time.
symmetric-encryption command.Ruby 3.2 or later, and Rails 7.2 or later when used with Rails. Upgrading from an earlier version of this gem? See Upgrading.
IOStreams is a streaming library that makes compression,
encryption, file format, and storage location transparent to your code. It has direct support for
Symmetric Encryption, so a file name ending in .enc is encrypted or decrypted with the
configuration this gem already loaded. Reach for it when encryption is one step in a larger pipeline:
IOStreams.path("s3://my-bucket/customers.csv.gz.enc").each(:hash) do |record|
puts record["name"]
end
See Files and Streams for
when to use IOStreams and when SymmetricEncryption::Writer and SymmetricEncryption::Reader are
enough on their own.
Rocket Job is Ruby's missing batch system. It fully supports Symmetric Encryption to encrypt data in flight and at rest while running jobs in the background.
This project uses Semantic Versioning.
Although this library has assisted in meeting PCI Compliance and has passed previous PCI audits, it in no way guarantees that PCI Compliance will be achieved by anyone using this library.
Ruby
100.0%
Encrypt data at rest in Ruby and Rails, with keys held outside your source code.
See the codeEncrypt data at rest in Ruby and Rails, with keys held outside your source code.
database.yml and other configuration files.Documentation: encryption.reidmorrison.com
Rails 7 added Active Record encryption. If everything you need to encrypt is an Active Record attribute, use that instead. It is built in, and it is maintained by the Rails team.
This gem covers what it does not: Mongoid fields, whole files and streams, standalone Ruby, passwords decrypted before Rails has finished booting, keys held in a cloud KMS, and rotating the key of a value that has to stay queryable. See Do you need it? for the full comparison.
gem "symmetric-encryption"
Generate a configuration file and a key for every environment:
symmetric-encryption --generate --app-name my_app
Encrypt an Active Record attribute. The column is a string, since the encrypted value is text:
class Person < ActiveRecord::Base
attribute :ssn, :encrypted
end
person = Person.create!(name: "Jack", ssn: "123456789")
person.ssn
# => "123456789"
Continue with the Guide, which builds up from here one step at a time.
symmetric-encryption command.Ruby 3.2 or later, and Rails 7.2 or later when used with Rails. Upgrading from an earlier version of this gem? See Upgrading.
IOStreams is a streaming library that makes compression,
encryption, file format, and storage location transparent to your code. It has direct support for
Symmetric Encryption, so a file name ending in .enc is encrypted or decrypted with the
configuration this gem already loaded. Reach for it when encryption is one step in a larger pipeline:
IOStreams.path("s3://my-bucket/customers.csv.gz.enc").each(:hash) do |record|
puts record["name"]
end
See Files and Streams for
when to use IOStreams and when SymmetricEncryption::Writer and SymmetricEncryption::Reader are
enough on their own.
Rocket Job is Ruby's missing batch system. It fully supports Symmetric Encryption to encrypt data in flight and at rest while running jobs in the background.
This project uses Semantic Versioning.
Although this library has assisted in meeting PCI Compliance and has passed previous PCI audits, it in no way guarantees that PCI Compliance will be achieved by anyone using this library.
Ruby
100.0%