module SecureDataBag::Encryptor
Public Class Methods
new(raw_hash, secret, metadata = {})
click to toggle source
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.
@param raw_hash [Hash] the raw hash to encrypt @param secret [String] the secret to encrypt with @param metadata [Hash] the optional metdata to configure the encryptor @return [SecureDataBag::NestedDecryptor] the object capable of decrypting @since 3.0.0
# File lib/secure_data_bag/encryptor.rb, line 17 def self.new(raw_hash, secret, metadata = {}) metadata = Mash.new(metadata) format = (metadata[:encryption_format] || metadata[:decryption_format]) case format when 'encrypted' SecureDataBag::FlatEncryptor.new(raw_hash, secret, metadata) else SecureDataBag::NestedEncryptor.new(raw_hash, secret, metadata) end end