class Ronin::CLI::Commands::Hmac
Calculates a [Hash-based Message Authentication Code (HMAC)] for data.
[HMAC]: en.wikipedia.org/wiki/HMAC
## 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
Public Instance Methods
process_string(string)
click to toggle source
Calculates the Hash-based Message Authentication Code (HMAC) for the given string.
@param [String] string
The input string.
@return [String]
The HMAC string.
# 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)
click to toggle source
Runs the ‘ronin hmac` command.
@param [Array<String>] files
Additional files to process.
Calls superclass method
# 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