Sha256: 7f9254aee79e105a28fefc514ec42fedf7f1e0ce7eb6a2f609b998e1225ff1c7
Contents?: true
Size: 953 Bytes
Versions: 4
Compression:
Stored size: 953 Bytes
Contents
class CesarCifrado attr_accessor :dato def initialize(dato = nil) @dato = dato end def cesar(dato, rotasiones, orientacion = 1) alfa_mayus = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" alfa_minus = "abcdefghijklmnopqrstuvwxyz" alf = 26 lit_mayus = 65 lit_minus = 97 cad_rot = "" print "\e[1;32m[\e[0m+\e[1;32m]\e[0m CipherText: " for letra in dato.chars if !letra.match(/^[[:alpha:]]$/) cad_rot += letra next end alfabeto = alfa_mayus limit = lit_mayus if letra == letra.downcase alfabeto = alfa_minus limit = lit_minus end var_ascii = letra.ord rot_ver = rotasiones * orientacion new_pos = (var_ascii - limit + rot_ver) % alf cad_rot = alfabeto[new_pos] print cad_rot end puts "\n\e[1;32m[\e[0m+\e[1;32m]\e[0m Rotations Number: #{rotasiones}" end end CifraCesar = CesarCifrado.new DecifraCesar = CesarCifrado.new
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cobreak-0.0.6 | lib/cobreak/Cesar.rb |
cobreak-0.0.5 | lib/cobreak/Cesar.rb |
cobreak-0.0.4 | lib/cobreak/Cesar.rb |
cobreak-0.0.3 | lib/cobreak/Cesar.rb |