Sha256: 8d299c3990ec8891fa3795f7b5c43be52ef989cbbe9683f582a1075233ebdf2e

Contents?: true

Size: 775 Bytes

Versions: 84

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module Encryption
    # A key is a container for a given +secret+
    #
    # Optionally, it can include +public_tags+. These tags are meant to be stored
    # in clean (public) and can be used, for example, to include information that
    # references the key for a future retrieval operation.
    class Key
      attr_reader :secret, :public_tags

      def initialize(secret)
        @secret = secret
        @public_tags = Properties.new
      end

      def self.derive_from(password)
        secret = ActiveRecord::Encryption.key_generator.derive_key_from(password)
        ActiveRecord::Encryption::Key.new(secret)
      end

      def id
        Digest::SHA1.hexdigest(secret).first(4)
      end
    end
  end
end

Version data entries

84 entries across 81 versions & 9 rubygems

Version Path
activerecord-7.2.0.beta1 lib/active_record/encryption/key.rb
activerecord-7.1.3.2 lib/active_record/encryption/key.rb
activerecord-7.1.3.1 lib/active_record/encryption/key.rb
activerecord-7.0.8.1 lib/active_record/encryption/key.rb
activerecord-7.1.3 lib/active_record/encryption/key.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/key.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/encryption/key.rb
activerecord-7.1.2 lib/active_record/encryption/key.rb
activerecord-7.1.1 lib/active_record/encryption/key.rb
activerecord-7.1.0 lib/active_record/encryption/key.rb
activerecord-7.1.0.rc2 lib/active_record/encryption/key.rb
activerecord-7.1.0.rc1 lib/active_record/encryption/key.rb
activerecord-7.1.0.beta1 lib/active_record/encryption/key.rb
activerecord-7.0.8 lib/active_record/encryption/key.rb
activerecord-7.0.7.2 lib/active_record/encryption/key.rb
activerecord-7.0.7.1 lib/active_record/encryption/key.rb
activerecord-7.0.7 lib/active_record/encryption/key.rb
activerecord-7.0.6 lib/active_record/encryption/key.rb
activerecord-7.0.5.1 lib/active_record/encryption/key.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/encryption/key.rb