lib/rapid-vaults/generate.rb in rapid-vaults-1.1.2 vs lib/rapid-vaults/generate.rb in rapid-vaults-1.2.0
- old
+ new
@@ -5,16 +5,17 @@
require 'openssl'
# setup parameters
cipher = OpenSSL::Cipher.new('aes-256-gcm').encrypt
- if settings[:ui] == :cli
+ case settings[:ui]
+ when :cli
# output to file
File.write("#{settings[:outdir]}key.txt", cipher.random_key)
File.write("#{settings[:outdir]}nonce.txt", cipher.random_iv)
puts "Your key.txt and nonce.txt have been generated in #{settings[:outdir]}."
- elsif settings[:ui] == :api
- # output to string
+ when :api
+ # return as array
[cipher.random_key, cipher.random_iv]
end
end
# generates a private and public key