百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

symmetric-encryption

> DevOps
开源

使用 OpenSSL 为 Ruby 项目实现对称加密

475 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

使用 OpenSSL 为 Ruby 项目实现对称加密

Symmetric Encryption

Encrypt data at rest in Ruby and Rails, with keys held outside your source code.

  • Active Record attributes and Mongoid fields.
  • Passwords in database.yml and other configuration files.
  • Entire files and streams, of any size, without loading them into memory.
  • Keys in a keystore: a file, an environment variable, AWS KMS, or Google Cloud KMS.
  • Key rotation without downtime, since every encrypted value records which key encrypted it.

Documentation: encryption.reidmorrison.com

Do you need it?

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.

Quick start

ruby
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:

ruby
class Person  "123456789"

Continue with the Guide, which builds up from here one step at a time.

Documentation

  • Guide — the library, one step at a time.
  • Configuration — the configuration file and every keystore.
  • Rails — encrypted Active Record attributes.
  • Mongoid — encrypted Mongoid fields.
  • Files — encrypted files and streams.
  • Command Line — the symmetric-encryption command.
  • Key Rotation — introducing a new key without downtime.
  • Security — authenticated encryption and PCI compliance.
  • Upgrading — what changes between major versions.
  • API — the method reference.

Supported versions

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.

Sister projects

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:

ruby
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.

Author

Reid Morrison

Contributors

Versioning

This project uses Semantic Versioning.

Disclaimer

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubycomplianceencryptionopensslpci

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理