lib/ridley/chef_objects/data_bag_item_obect.rb
# Decrypts an individual value stored inside the data bag item.
#
# @example
#   data_bag_item.decrypt_value("Xk0E8lV9r4BhZzcg4wal0X4w9ZexN3azxMjZ9r1MCZc=")
#     => {test: {database: {username: "test"}}}
#
# @param [String] an encrypted String value
#
# @return [Hash] a decrypted attribute value
Decrypts an individual value stored inside the data bag item.
Decrypts an individual value stored inside the data bag item .
def decrypt_value(value)
      if encrypted_data_bag_secret.nil?
        raise Errors::EncryptedDataBagSecretNotSet
      end
      decoded_value = Base64.decode64(value)
      cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
      cipher.decrypt
      cipher.pkcs5_keyivgen(encrypted_data_bag_secret)
      decrypted_value = cipher.update(decoded_value) + cipher.final
      YAML.load(decrypted_value)
    end
def decrypt_value ( value ) if encrypted_data_bag_secret . nil? raise Errors :: EncryptedDataBagSecretNotSet end decoded_value = Base64 . decode64 ( value ) cipher = OpenSSL :: Cipher :: Cipher . new ( 'aes-256-cbc' ) cipher . decrypt cipher . pkcs5_keyivgen ( encrypted_data_bag_secret ) decrypted_value = cipher . update ( decoded_value ) + cipher . final YAML . load ( decrypted_value ) end
Decrypts an individual value stored inside the data bag item.
Decrypts an individual value stored inside the data bag item .
a decrypted attribute value
a decrypted attribute value
Hash
value
<not_specific>
<not_specific>
an encrypted String value
an encrypted String value
example
data_bag_item.decrypt_value("Xk0E8lV9r4BhZzcg4wal0X4w9ZexN3azxMjZ9r1MCZc=") => {test: {database: {username: "test"}}}
data_bag_item . decrypt_value ( " Xk0E8lV9r4BhZzcg4wal0X4w9ZexN3azxMjZ9r1MCZc = " ) = > { test : { database : { username : " test " }}}