Class: SecureDataBag::NestedEncryptor
- Inherits:
-
Object
- Object
- SecureDataBag::NestedEncryptor
- Defined in:
- lib/secure_data_bag/encryptor.rb
Overview
Encryptor object responsable for encrypting the raw_hash with the secret. This object will recursively step through the raw_hash, looking for keys matching encrypted_keys and encrypt their values.
Instance Attribute Summary collapse
-
#decrypted_hash ⇒ Object
readonly
The decrypted hash to encrypt.
-
#encrypted_hash ⇒ Object
readonly
The encrypted hash generated.
-
#encrypted_keys ⇒ Object
readonly
The keys to encrypt.
-
#metadata ⇒ Object
readonly
The metadata used to create the encrypted_hash.
Instance Method Summary collapse
-
#encrypt ⇒ Hash
Method called to encrpt the data structure and return it.
-
#encrypt! ⇒ Hash
(also: #for_encrypted_item)
Method called to encrpt the data structure and return it.
-
#initialize(decrypted_hash, secret, metadata = {}) ⇒ NestedEncryptor
constructor
Initializer.
Constructor Details
#initialize(decrypted_hash, secret, metadata = {}) ⇒ NestedEncryptor
Initializer
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/secure_data_bag/encryptor.rb', line 118 def initialize(decrypted_hash, secret, = {}) @secret = secret @metadata = @encrypted_hash = {} @encrypted_keys = case [:encryption_format] when 'plain' then @encrypted_keys = [] else [:encrypted_keys] || [] end @decrypted_hash = decrypted_hash end |
Instance Attribute Details
#decrypted_hash ⇒ Object (readonly)
The decrypted hash to encrypt
108 109 110 |
# File 'lib/secure_data_bag/encryptor.rb', line 108 def decrypted_hash @decrypted_hash end |
#encrypted_hash ⇒ Object (readonly)
The encrypted hash generated
104 105 106 |
# File 'lib/secure_data_bag/encryptor.rb', line 104 def encrypted_hash @encrypted_hash end |
#encrypted_keys ⇒ Object (readonly)
The keys to encrypt
100 101 102 |
# File 'lib/secure_data_bag/encryptor.rb', line 100 def encrypted_keys @encrypted_keys end |
#metadata ⇒ Object (readonly)
The metadata used to create the encrypted_hash
111 112 113 |
# File 'lib/secure_data_bag/encryptor.rb', line 111 def @metadata end |
Instance Method Details
#encrypt ⇒ Hash
Method called to encrpt the data structure and return it.
139 140 141 |
# File 'lib/secure_data_bag/encryptor.rb', line 139 def encrypt encrypt_data(@decrypted_hash) end |
#encrypt! ⇒ Hash Also known as: for_encrypted_item
Method called to encrpt the data structure and return it.
132 133 134 |
# File 'lib/secure_data_bag/encryptor.rb', line 132 def encrypt! @encrypted_hash = encrypt end |