5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cobreak/decifrado.rb', line 5
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
|