Class: Unisec::CLI::Commands::Hexdump

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/unisec/cli/hexdump.rb

Overview

CLI command unisec hexdumps for the class Hexdump from the lib.

Example:

$ unisec hexdump "ACCEIS"
UTF-8: 41 43 43 45 49 53
UTF-16BE: 0041 0043 0043 0045 0049 0053
UTF-16LE: 4100 4300 4300 4500 4900 5300
UTF-32BE: 00000041 00000043 00000043 00000045 00000049 00000053
UTF-32LE: 41000000 43000000 43000000 45000000 49000000 53000000

$unisec hexdump "ACCEIS" --enc utf16le
4100 4300 4300 4500 4900 5300

Instance Method Summary collapse

Instance Method Details

#call(input: nil, **options) ⇒ Object

Hexdump of all Unicode encodings.

Parameters:

  • input (String) (defaults to: nil)

    Input string to encode



35
36
37
38
39
40
41
42
43
# File 'lib/unisec/cli/hexdump.rb', line 35

def call(input: nil, **options)
  input = $stdin.read.chomp if input == '-'
  if options[:enc].nil?
    puts Unisec::Hexdump.new(input).display
  else
    # using send() is safe here thanks to the value whitelist
    puts Unisec::Hexdump.send(options[:enc], input)
  end
end