class Ronin::CLI::Commands::CipherCommand
Base class for all commands which use ciphers.
Public Instance Methods
cipher(**kwargs)
click to toggle source
Initializes a new cipher.
@param [Hash{Symbol => Object}] kwargs
Additional keyword arguments for `Ronin::Support::Crypto::Cipher#initialize`.
@return [Ronin::Support::Crypto::Cipher]
The new cipher object.
# File lib/ronin/cli/cipher_command.rb, line 129 def cipher(**kwargs) Support::Crypto::Cipher.new( options[:cipher], key: @key, hash: options[:hash], password: options[:password], **kwargs ) end
open_file(path,&block)
click to toggle source
Opens the file in binary mode.
@param [Stirng] path
The path to the file to open.
@yield [file]
If a block is given, the newly opened file will be yielded. Once the block returns the file will automatically be closed.
@yieldparam [File] file
The newly opened file.
@return [File, nil]
If no block is given, the newly opened file object will be returned. If no block was given, then `nil` will be returned.
Calls superclass method
# File lib/ronin/cli/cipher_command.rb, line 115 def open_file(path,&block) super(path,'rb',&block) end
process_input(input)
click to toggle source
Decrypts the input stream.
@param [IO, StringIO] input
The input stream to decrypt.
# File lib/ronin/cli/cipher_command.rb, line 144 def process_input(input) cipher.stream(input, block_size: @block_size, output: stdout) end
run(*files)
click to toggle source
Runs the ‘ronin encrypt` command.
@param [Array<String>] files
Optional files to encrypt.
Calls superclass method
# File lib/ronin/cli/cipher_command.rb, line 84 def run(*files) if options[:list_ciphers] puts Support::Crypto::Cipher.supported return end unless (options[:key] || options[:key_file] || options[:password]) print_error "must specify --password, --key, or --key-file" exit(1) end super(*files) end