Class: Cyclid::Cli::Secret
Overview
‘secret’ sub-command
Instance Method Summary collapse
Instance Method Details
#encrypt ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cyclid/cli/secret.rb', line 24 def encrypt # Get the organizations public key in a form we can use org = client.org_get(client.config.organization) der_key = Base64.decode64(org['public_key']) public_key = OpenSSL::PKey::RSA.new(der_key) # Get the secret in a safe manner print 'Secret: ' secret = STDIN.noecho(&:gets).chomp print "\r" # Encrypt with the public key encrypted = public_key.public_encrypt(secret) Formatter.colorize 'Secret', Base64.strict_encode64(encrypted) rescue StandardError => ex abort "Failed to encrypt secret: #{ex}" end |