Skip to content

Instantly share code, notes, and snippets.

@chaupt
Created June 21, 2010 04:06
Show Gist options
  • Save chaupt/446375 to your computer and use it in GitHub Desktop.
Save chaupt/446375 to your computer and use it in GitHub Desktop.
SacRuby Obfuscated Signature Ruby Quiz Solutions
#
# You'll want to snip these out separated into files or command line strings to try them out.
#
# John Miller's Signature
require"net/http";s=" abcdefghijklmnopqrstuvwxyz.@,\n"
v=":6=9<<5BLI18??K3?=0=L;?7CG5<<K3?=NNG50@B5C5>D081=<5D02I0GK0C81;5C@51B5"
puts v.unpack("c*").map{|i| s[i-48].chr}.join; Net::HTTP.get_print \
URI.parse("http://www.gutenberg.org/dirs/etext00/0ws2610.txt")
# Greg Weber's Signature Generator
puts "#{ARGV[0].each_char.map{|c|c[0]}.inspect}.map{|d|d.chr}.join"
# Ben Shell's Generator and Signatures
a='Blne@enbwje anRmsuihbney l Sldh.eecvloelml >o< pe|em raA i '.split('');
b=[]; (a.length/3).times { |i| b << a.slice(i*3,3) }
b.transpose.join.strip.split('|').each { |t| puts t.strip }
# Move this to its own file
# encode an argument
s=ARGV[0]
orig=s
l=s.length
n=3
pad = l % n
column=(l/n + pad)
l=column*n
s=s.ljust(l, ' ')
a=[]
n.times { |i|
a << s.slice(i*column,column).split('')
}
e=a.transpose.join
# print the signature
puts
puts "The following input will be encoded:"
orig.split('|').each { |t| puts t.strip }
puts "(Pipe symbols are converted to new lines)"
puts
puts "Ruby program:"
puts "a='" + e + "'.split('');"
puts "b=[]; (a.length/3).times { |i| b << a.slice(i*3,3) }"
puts "b.transpose.join.strip.split('|').each { |t| puts t.strip }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment