Class: CoBreak::Box::Cryptgraphy

Inherits:
Object
  • Object
show all
Defined in:
lib/cobreak/cobreak_opt.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
74
# File 'lib/cobreak/cobreak_opt.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 HALF-MD5 SHA1 SHA2-224 SHA2-256 SHA2-384 SHA2-512 SHA3-224 SHA3-256 SHA3-384 SHA3-512 RIPEMD-160 TIGER-160 DOUBLE-SHA1 BLAKE2S-128 BLAKE2S-160 BLAKE2B-160 BLAKE2S-224 BLAKE2S-256 BLAKE2B-256 BLAKE2B-384 BLAKE2B-512 WHIRLPOOL GOST-STREEBOG-256 GOST-STREEBOG-512 SHAKE-128]
  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.upcase, @options.algo)
        #DeCrypt::show(@options.decrypt, @options.algo)
      end
    end
  else
    abort "\e[31m[\e[37m✘\e[31m]\e[37m Invalid Hash Format"
  end
end