license updating

This commit is contained in:
Yan
2017-12-08 14:27:10 +06:30
parent 681b5afebc
commit 5310e3e534
4 changed files with 34 additions and 11 deletions

View File

@@ -31,15 +31,35 @@ class MyAesCrypt
file_path = "config/shops.json"
aes_key, aes_iv = export_key(passphrase)
tmpHash = {
"lookup" => passphrase,
"key" => aes_key,
"iv" => aes_iv
"lookup" => passphrase = {
"key" => aes_key,
"iv" => aes_iv
}
}
File.open(file_path, "w") { |io|
io.write(tmpHash.to_json)
}
shop_data = File.read(file_path)
if shop_data != ""
shop_json = JSON.parse(shop_data)
byebug
shop_json.each do |j|
if j == passphrase
j.each do |k|
return k["key"], k["iv"]
end
end
end
shop_json << tmpHash
File.open(file_path, "w") { |io|
io.puts JSON.pretty_generate(shop_json)
}
else
File.open(file_path, "w") { |io|
io.write(tmpHash.to_json)
}
end
return aes_key, aes_iv
end
private