Class: Ronin::CLI::Commands::Hmac Private

Inherits:
StringProcessorCommand show all
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 [options] [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

Since:

  • 2.0.0

Instance Attribute Summary

Attributes included from KeyOptions

#key

Attributes inherited from StringProcessorCommand

#input_values

Instance Method Summary collapse

Methods included from KeyOptions

included

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.

Parameters:

  • string (String)

    The input string.

Returns:

  • (String)

    The HMAC string.

Since:

  • 2.0.0



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: options[: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.

Parameters:

  • files (Array<String>)

    Additional files to process.

Since:

  • 2.0.0



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