Basecamp 把他们用在 Hey.com 的字段加密功能开源出来了,不是一个 gem,而是集成到 ActiveRcord。这可以替代 attr_encrypted 等加密 gem,减少维护的依赖。
用起来会是这个样子:
class Person < ApplicationRecord
encrypts :name
encrypts :email_address, deterministic: true
end
# Person.find_by(name: "jorge") # doesn't work
# Person.find_by(email_address: "[email protected]") # works
详情可以看 PR(进行中):https://github.com/rails/rails/pull/41659