Module: SecureDataBag::Encryptor

Defined in:
lib/secure_data_bag/encryptor.rb

Class Method Summary collapse

Class Method Details

.new(raw_hash, secret, metadata = {}) ⇒ SecureDataBag::NestedDecryptor

Instantiate an Encryptor object responsable for encrypting the raw_hash with the secret.

The optional metadata may contain hints as to how we should encrypt the raw_hash. Should hints not be provided, this will do it’s best to detect the appropriate defaults.

Parameters:

  • raw_hash (Hash)

    the raw hash to encrypt

  • secret (String)

    the secret to encrypt with

  • metadata (Hash) (defaults to: {})

    the optional metdata to configure the encryptor

Returns:

Since:

  • 3.0.0



17
18
19
20
21
22
23
24
25
26
# File 'lib/secure_data_bag/encryptor.rb', line 17

def self.new(raw_hash, secret,  = {})
   = Mash.new()
  format = ([:encryption_format] || [:decryption_format])
  case format
  when 'encrypted'
    SecureDataBag::FlatEncryptor.new(raw_hash, secret, )
  else
    SecureDataBag::NestedEncryptor.new(raw_hash, secret, )
  end
end