Class: CoBreak::Box::Cryptgraphy

Inherits:
Object
  • Object
show all
Defined in:
lib/cobreak/cobreak.rb

Class Method Summary collapse

Class Method Details

.cryptObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cobreak/cobreak.rb', line 49

def self.crypt()
  @options = $options
  @options.encrypt = "" if @options.encrypt.nil? == true
  @options.decrypt = "" if @options.decrypt.nil? == true
  show = OpenStruct.new
  show.crypt = %w[MD4 MD5 SHA1 SHA224 SHA256 SHA384 SHA512 RIPEMD160]
  if (show.crypt.include?(@options.encrypt.upcase)) or (show.crypt.include?(@options.decrypt.upcase));
    if (File.exists?(@options.algo));
      IO.foreach(@options.algo){|line|
        line.chomp!
        EnCrypt::show(@options.encrypt, line) if (show.crypt.include?(@options.encrypt.upcase))
        DeCrypt::show(@options.decrypt, line) if (show.crypt.include?(@options.decrypt.upcase))
      }
    else
      if (show.crypt.include?(@options.encrypt.upcase))
        EnCrypt::show(@options.encrypt, @options.algo)
      end
      if (show.crypt.include?(@options.decrypt.upcase))
        DeCrypt::show(@options.decrypt, @options.algo)
      end
    end
  else
    abort "\e[31m[\e[37m✘\e[31m]\e[37m Invalid Hash Format"
  end
end