Class: CICI::Decrypt
Constant Summary
Constants included from CICI
DECRYPT_IV_ENV_VAR, DECRYPT_KEY_ENV_VAR
Instance Method Summary collapse
- #decrypt(key, iv) ⇒ Object
-
#initialize(ui, config) ⇒ Decrypt
constructor
A new instance of Decrypt.
- #start(set) ⇒ Object
Constructor Details
Instance Method Details
#decrypt(key, iv) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cici/decrypt.rb', line 40 def decrypt(key, iv) @ui.verbose('Decrypting secrets encrypted file.') decipher = OpenSSL::Cipher.new('AES-256-CBC') decipher.decrypt decipher.key = key decipher.iv = iv plain = decipher.update(File.read(@config.output_file_encrypted)) + decipher.final plain end |
#start(set) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cici/decrypt.rb', line 24 def start(set) @set = set assert_encrypted_secret_exist plain = decrypt(Base64.decode64(@util.get_env(CICI::DECRYPT_KEY_ENV_VAR)), Base64.decode64(@util.get_env(CICI::DECRYPT_IV_ENV_VAR))) if !plain.empty? File.write(@config.output_file, plain) else @ui.fail('Wrong key/iv pair for decryption.') end decompress copy_files @ui.success('Files successfully decrypted and copied to their destination!') end |