Class: Cheftacular::Decryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/cheftacular/decryptor.rb

Constant Summary collapse

ALGORITHM =
'aes-256-cbc'

Instance Method Summary collapse

Constructor Details

#initialize(data_bag_secret) ⇒ Decryptor

Returns a new instance of Decryptor.



6
7
8
# File 'lib/cheftacular/decryptor.rb', line 6

def initialize data_bag_secret
  @data_bag_secret = data_bag_secret
end

Instance Method Details

#return_decrypted_hash(input_hash, return_hash = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cheftacular/decryptor.rb', line 10

def return_decrypted_hash input_hash, return_hash={}
  input_hash.each_pair do |key, value_hash|
    next if key =~ /id/
    next if value_hash['iv'].nil? || value_hash['iv'].empty?

    return_hash[key] = JSON.parse(decrypt_hash(value_hash)).to_hash["json_wrapper"]
  end

  return_hash['id'] = input_hash['id']

  return_hash
end