Skip to content

Instantly share code, notes, and snippets.

@popsikle
Last active September 28, 2015 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popsikle/bd5024b5bdf8e78db52e to your computer and use it in GitHub Desktop.
Save popsikle/bd5024b5bdf8e78db52e to your computer and use it in GitHub Desktop.
key_path = 'secret_key'
data_path = databags/test.json'
secret = Chef::EncryptedDataBagItem.load_secret(key_path.realpath)
data = JSON.parse(File.read(data_path.realpath))
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
puts JSON.pretty_generate(encrypted_data)
plain_data = ::Chef::EncryptedDataBagItem.new(encrypted_data, secret).to_hash
puts JSON.pretty_generate(plain_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment