Created
January 9, 2015 14:16
-
-
Save trekr5/b57fc346edf3c9907a26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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