class CoBreak::Box::Cryptgraphy

Public Class Methods

crypt() click to toggle source
# 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