Sha256: 208e43a38f4d37f81933e22bc8c178679d4dce8bb765f915266b2f9b41f413b9

Contents?: true

Size: 1.65 KB

Versions: 9

Compression:

Stored size: 1.65 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# Ruby internal
require 'pp'
# Project internal
require 'haiti'
# External
require 'docopt'
require 'paint'

doc = <<~DOCOPT
  HAITI  (HAsh IdenTifIer)

  Usage:
    haiti [options] <hash>
    haiti -h | --help
    haiti --version

  Options:
    --no-color      Disable colorized output
    -e, --extended  List all possible hash algorithms including ones using salt
    --short         Display in a short format: do not display hashcat and john the ripper references
    --hashcat-only  Show only hashcat references
    --john-only     Show only john the ripper references
    --debug         Display arguments
    -h, --help      Show this screen
    --version       Show version

  Examples:
    haiti -e d41d8cd98f00b204e9800998ecf8427e
    haiti --no-color --short d41d8cd98f00b204e9800998ecf8427e
DOCOPT

begin
  args = Docopt.docopt(doc, version: HashIdentifier::VERSION)
  Paint.mode = 0 if args['--no-color']
  pp args if args['--debug']
  # use case 1, using the tool
  if args['<hash>']
    hi = HashIdentifier.new(args['<hash>'])
    if hi.type.empty?
      puts 'Unknown hash type'
      exit(0)
    end
    hi.type.each do |type|
      next if type.extended && !args['--extended']

      print Paint[type.name, :bold]
      print Paint[" [HC: #{type.hashcat}]", :blue] unless type.hashcat.nil? || args['--short'] || args['--john-only']
      print Paint[" [JtR: #{type.john}]", :green] unless type.john.nil? || args['--short'] || args['--hashcat-only']
      puts
    end
  end
  # use case 2, help: already handled by docopt
  # use case 3, version: already handled by docopt
rescue Docopt::Exit => e
  puts e.message
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
haiti-hash-1.3.0 bin/haiti
haiti-hash-1.2.3 bin/haiti
haiti-hash-1.2.2 bin/haiti
haiti-hash-1.2.1 bin/haiti
haiti-hash-1.2.0 bin/haiti
haiti-hash-1.1.3 bin/haiti
haiti-hash-1.1.2 bin/haiti
haiti-hash-1.1.1 bin/haiti
haiti-hash-1.1.0 bin/haiti