Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
class Vigenere
def diagram(plaintext)
@key = [];@plain = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z); (1..plaintext.gsub(/\W/,'').split(//).length).each {@key.push(@plain[Random.rand(0..25)])}; @cipher = []; x = 0; plaintext.gsub(/\W/, '').split(//).each {|plain_char| c = @plain.rotate(@plain.index(@key[x].downcase)); @cipher.push(@plain[c.index("#{plain_char.downcase}")]); x += 1 }; print "KEY:\t #{@key.join('-').upcase}\n"; print "PLAIN:\t #{plaintext.gsub(/\W/, '').split(//).join('-').upcase}\n";print "CIPHER:\t #{@cipher.join('-').upcase}\n";print "\n\n";x=0; while x < 26 do print "\t #{@plain.rotate(x).join('-').upcase}\n"; x += 1;
end
return puts "\nKEY:\t\t #{@key.join}\nCIPHERTEXT:\t #{@cipher.join}"
end
def encrypt(plaintext)

Keybase proof

I hereby claim:

  • I am spyd3r on github.
  • I am spyd3r (https://keybase.io/spyd3r) on keybase.
  • I have a public key whose fingerprint is 1BBE A766 6358 9CA9 1E59 70A1 174E 575F 3147 9711

To claim this, I am signing this object: