Class: Ronin::CLI::Commands::Hmac Private
- Inherits:
-
StringProcessorCommand
- Object
- Core::CLI::Command
- Ronin::CLI::Command
- FileProcessorCommand
- StringProcessorCommand
- Ronin::CLI::Commands::Hmac
- Includes:
- KeyOptions
- Defined in:
- lib/ronin/cli/commands/hmac.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Calculates a Hash-based Message Authentication Code (HMAC) for data.
Usage
ronin hmac [] [FILE ...]
Options
-f, --file FILE Optional file to process
--string STRING Optional string to process
-M, --multiline Process each line separately
-n, --keep-newlines Preserves newlines at the end of each line
-H md5|sha1|sha256|sha512, Hash algorithm to use (Default: sha1)
--hash
-k, --key STRING The key String
-K, --key-file FILE The key file
-h, --help Print help information
Arguments
[FILE ...] Optional file(s) to process
Instance Attribute Summary
Attributes included from KeyOptions
Attributes inherited from StringProcessorCommand
Instance Method Summary collapse
-
#process_string(string) ⇒ String
private
Calculates the Hash-based Message Authentication Code (HMAC) for the given string.
-
#run(*files) ⇒ Object
private
Runs the
ronin hmac
command.
Methods included from KeyOptions
Methods inherited from StringProcessorCommand
#initialize, #print_string, #process_input
Methods inherited from FileProcessorCommand
#open_file, #process_file, #process_input
Constructor Details
This class inherits a constructor from Ronin::CLI::StringProcessorCommand
Instance Method Details
#process_string(string) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates the Hash-based Message Authentication Code (HMAC) for the given string.
93 94 95 96 97 |
# File 'lib/ronin/cli/commands/hmac.rb', line 93 def process_string(string) hmac = Support::Crypto.hmac(string, key: self.key, digest: [:hash]) hmac.hexdigest end |
#run(*files) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin hmac
command.
74 75 76 77 78 79 80 81 |
# File 'lib/ronin/cli/commands/hmac.rb', line 74 def run(*files) unless @key print_error "must specify --key or --key-file" exit(-1) end super(*files) end |