Sha256: fc00680c712990ef46d029de12f9cd1de91fa9e6a4f7999346f0aa7d7c54ec94

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'ascii85'

module CoBreak
  class Decifrado
    def self.cipher(mode, dato)
      decipher = OpenStruct.new
      decipher.mode = mode
      decipher.dato = dato
      if (decipher.mode.eql?('base16'))
        decipher.result = CoBreak::Cipher::Base16.decode(decipher.dato)
      elsif (decipher.mode.eql?('base32'))
        decipher.result = CoBreak::Cipher::Base32.decode(decipher.dato)
      elsif (decipher.mode.eql?('base64'))
        decipher.result = CoBreak::Cipher::Base64.decode(decipher.dato)
      elsif (decipher.mode.eql?('ascii85'))
        decipher.result = Ascii85.decode(decipher.dato)
      elsif (decipher.mode.eql?('cesar'))
        decipher.result = CoBreak::Cipher::Cesar.decode(decipher.dato, ARGV[0].to_i)
      elsif (decipher.mode.eql?('binary'))
        decipher.result = CoBreak::Cipher::Binary.decode(decipher.dato)
      end
      unless (decipher.result.nil?) or (decipher.result.eql?(decipher.dato))
        puts "\n\e[1;32m[\e[37m+\e[1;32m]\e[37m DecipherText: #{decipher.result}"
        puts "\e[1;32m[\e[37m+\e[1;32m]\e[37m Number Rotations: #{ARGV[0]}" if (decipher.mode.eql?('cesar'))
      else
        puts "\e[1;31m[\e[37m+\e[1;31m]\e[37m Not Cipher Text..."
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
cobreaktws-1.0.4 lib/cobreak/decifrado.rb
cobreaktw-1.0.4 lib/cobreak/decifrado.rb
cobreakk-1.0.4 lib/cobreak/decifrado.rb