#!/bin/env ruby module CoBreak class Box def self.var(options) @options = options $options = options end begin require 'cobreak/cifrado' require 'cobreak/decifrado' require 'cobreak/Cesar' require 'cobreak/encrypt' require 'cobreak/decrypt' rescue LoadError => e puts e.message puts "A file is missing from the repository" puts "" exit(1) end #encoding and decoding algoritmhs class Cipher def self.coding() @options = $options @options.enc = "" if @options.enc.nil? == true @options.dec = "" if @options.dec.nil? == true if (@options.enc.casecmp?('base16')) or (@options.dec.casecmp?('base16')); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! Cifra::base16(line.to_s) if (@options.enc.casecmp?('base16')) Decifra::base16(line.to_s) if (@options.dec.casecmp?('base16')) } else; Cifra::base16(@options.algo.to_s) if (@options.enc.casecmp?('base16')) Decifra::base16(@options.algo.to_s) if (@options.dec.casecmp?('base16')) end elsif (@options.enc.casecmp?('base32')) or (@options.dec.casecmp?('base32')); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! Cifra::base32(line.to_s) if (@options.enc.casecmp?('base32')) Decifra::base32(line.to_s) if (@options.dec.casecmp('base32')) } else; Cifra::base32(@options.algo.to_s) if (@options.enc.casecmp?('base32')) Decifra::base32(@options.algo.to_s) if (@options.dec.casecmp?('base32')) end elsif (@options.enc.casecmp?('base64')) or (@options.dec.casecmp?('base64')); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! Cifra::base64(line.to_s) if (@options.enc.casecmp?('base64')) Decifra::base64(line.to_s) if (@options.dec.casecmp?('base64')) } else; Cifra::base64(@options.algo.to_s) if (@options.enc.casecmp?('base64')) Decifra::base64(@options.algo.to_s) if (@options.dec.casecmp?('base64')) end elsif (@options.enc.casecmp?('ascii85')) or (@options.dec.casecmp?('ascii85')); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! Cifra::ascii85(line.to_s) if (@options.enc.casecmp?('ascii85')) Decifra::ascii85(line.to_s) if (@options.dec.casecmp?('ascii85')) } else; Cifra::ascii85(@options.algo.to_s) if (@options.enc.casecmp?('ascii85')) Decifra::ascii85(@options.algo.to_s) if (@options.dec.casecmp?('ascii85')) end elsif (@options.enc.casecmp?('binary')) or (@options.dec.casecmp?('binary')); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! Cifra::binary(line.to_s) if (@options.enc.casecmp?('binary')) Decifra::binary(line.to_s) if (@options.dec.casecmp?('binary')) } else; Cifra::binary(@options.algo.to_s) if (@options.enc.casecmp?('binary')) Decifra::binary(@options.algo.to_s) if (@options.dec.casecmp?('binary')) end elsif (@options.enc.casecmp?('cesar')) or (@options.dec.casecmp?('cesar')); dat = ARGV[0] if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! CifraCesar::cesar(line.to_s, dat.to_i) if (@options.enc.casecmp?('cesar')) DecifraCesar::cesar(line.to_s, dat.to_i, -1) if (@options.dec.casecmp?('cesar')) } else; CifraCesar::cesar(@options.algo.to_s, dat.to_i) if (@options.enc.casecmp?('cesar')) DecifraCesar::cesar(@options.algo.to_s, dat.to_i, -1) if (@options.dec.casecmp?('cesar')) end end end end class Cryptgraphy def self.crypt() @options = $options @options.encrypt = "" if @options.encrypt.nil? == true @options.decrypt = "" if @options.decrypt.nil? == true if (@options.encrypt.casecmp?("md4")) or (@options.decrypt.casecmp?("md4")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::md4(line) if (@options.encrypt.casecmp?("md4")) DeCrypt::md4(line) if (@options.decrypt.casecmp?("md4")) } else EnCrypt::md4(@options.algo) if (@options.encrypt.casecmp?("md4")) DeCrypt::md4(@options.algo) if (@options.decrypt.casecmp?("md4")) end elsif (@options.encrypt.casecmp?("md5")) or (@options.decrypt.casecmp?("md5")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::md5(line) if (@options.encrypt.casecmp?("md5")) DeCrypt::md5(line) if (@options.decrypt.casecmp?("md5")) } else EnCrypt::md5(@options.algo) if (@options.encrypt.casecmp?("md5")) DeCrypt::md5(@options.algo) if (@options.decrypt.casecmp?("md5")) end elsif (@options.encrypt.casecmp?("sha1")) or (@options.decrypt.casecmp?("sha1")) if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::sha1(line) if (@options.encrypt.casecmp?("sha1")) DeCrypt::sha1(line) if (@options.decrypt.casecmp?("sha1")) } else EnCrypt::sha1(@options.algo) if (@options.encrypt.casecmp?("sha1")) DeCrypt::sha1(@options.algo) if (@options.decrypt.casecmp?("sha1")) end elsif (@options.encrypt.casecmp?("sha224")) or (@options.decrypt.casecmp?("sha224")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::sha224(line) if (@options.encrypt.casecmp?("sha224")) DeCrypt::sha224(line) if (@options.decrypt.casecmp?("sha224")) } else EnCrypt::sha224(@options.algo) if (@options.encrypt.casecmp?("sha224")) DeCrypt::sha224(@options.algo) if (@options.decrypt.casecmp?("sha224")) end elsif (@options.encrypt.casecmp?("sha256")) or (@options.decrypt.casecmp?("sha256")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::sha256(line) if (@options.encrypt.casecmp?("sha256")) DeCrypt::sha256(line) if (@options.decrypt.casecmp?("sha256")) } else EnCrypt::sha256(@options.algo) if (@options.encrypt.casecmp?("sha256")) DeCrypt::sha256(@options.algo) if (@options.decrypt.casecmp?("sha256")) end elsif (@options.encrypt.casecmp?("sha384")) or (@options.decrypt.casecmp?("sha384")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::sha384(line) if (@options.encrypt.casecmp?("sha384")) DeCrypt::sha384(line) if (@options.decrypt.casecmp?("sha384")) } else EnCrypt::sha384(@options.algo) if (@options.encrypt.casecmp?("sha384")) DeCrypt::sha384(@options.algo) if (@options.decrypt.casecmp?("sha384")) end elsif (@options.encrypt.casecmp?("sha512")) or (@options.decrypt.casecmp?("sha512")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::sha512(line) if (@options.encrypt.casecmp?("sha512")) DeCrypt::sha512(line) if (@options.decrypt.casecmp?("sha512")) } else EnCrypt::sha512(@options.algo) if (@options.encrypt.casecmp?("sha512")) DeCrypt::sha512(@options.algo) if (@options.decrypt.casecmp?("sha512")) end elsif (@options.encrypt.casecmp?("ripemd160")) or (@options.decrypt.casecmp?("ripemd160")); if (File.exists?(@options.algo)); IO.foreach(@options.algo){|line| line.chomp! EnCrypt::ripemd160(line) if (@options.encrypt.casecmp?("ripemd160")) DeCrypt::ripemd160(line) if (@options.decrypt.casecmp?("ripemd160")) } else EnCrypt::ripemd160(@options.algo) if (@options.encrypt.casecmp?("ripemd160")) DeCrypt::ripemd160(@options.algo) if (@options.decrypt.casecmp?("ripemd160")) end end end end end end