lib/lockbox/encryptor.rb in lockbox-0.3.3 vs lib/lockbox/encryptor.rb in lockbox-0.3.4

- old
+ new

@@ -1,10 +1,12 @@ module Lockbox class Encryptor def initialize(**options) options = Lockbox.default_options.merge(options) @encode = options.delete(:encode) + # option may be renamed to binary: true + # warn "[lockbox] Lockbox 1.0 will default to encode: true. Pass encode: false to keep the current behavior." if @encode.nil? previous_versions = options.delete(:previous_versions) @boxes = [Box.new(**options)] + Array(previous_versions).map { |v| Box.new(key: options[:key], **v) } @@ -79,19 +81,22 @@ end target.content_type = source.content_type if source.respond_to?(:content_type) target.set_encoding(source.external_encoding) if source.respond_to?(:external_encoding) end + # TODO remove in 0.4.0 # legacy for attr_encrypted def self.encrypt(options) box(options).encrypt(options[:value]) end + # TODO remove in 0.4.0 # legacy for attr_encrypted def self.decrypt(options) box(options).decrypt(options[:value]) end + # TODO remove in 0.4.0 # legacy for attr_encrypted def self.box(options) options = options.slice(:key, :encryption_key, :decryption_key, :algorithm, :previous_versions) options[:algorithm] = "aes-gcm" if options[:algorithm] == "aes-256-gcm" Lockbox.new(options)