Skip to content

Instantly share code, notes, and snippets.

@trekr5
Created January 9, 2015 14:16
Show Gist options
  • Save trekr5/b57fc346edf3c9907a26 to your computer and use it in GitHub Desktop.
Save trekr5/b57fc346edf3c9907a26 to your computer and use it in GitHub Desktop.
#file called test4.json
{
"id": "angela",
, "password": {
"encrypted_data": "aI6rNH8ObHl9QtmhHHYdjF3lR3XuF7yoK6GnZyguL9k=\n",
"iv": "BtYOjuGpuayryqO81Hd7gA==\n",
"version": 1,
"cipher": "aes-256-cbc"
}
"host": "reset.local",
"chef_type": "data_bag_item",
"data_bag": "chicken"
}
so in irb, I have done this
filename = "test4.json"
text = File.readlines(filename)
text is an Array.
I went through each line to get the following encrypted password
y = [text[3],text[4],text[5],text[6],text[7]]
z = y.join
Then...
tex = File.read(filename)
puts = tex.gsub(/"#{z}"/, "newpassword")
File.open(filename, "w") {|file| file << puts}
Not working though!!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment