Class: Unisec::CLI::Commands::Dump::Hex

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

Overview

CLI command unisec dump hex for the class Hexdump from the lib.

Example:

$ unisec dump hex "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 dump hex "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



37
38
39
40
41
42
43
44
45
# File 'lib/unisec/cli/dump.rb', line 37

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