Skip to content

Instantly share code, notes, and snippets.

@beny
Created December 30, 2011 09:41
Show Gist options
  • Save beny/1539013 to your computer and use it in GitHub Desktop.
Save beny/1539013 to your computer and use it in GitHub Desktop.
h4[K3r5 mini help
#!/usr/bin/ruby
#
# simple Brute-Force recursive algorithm for decrypting crypt function
# try whatever you want in crypt function
#
# enjoy
require 'zlib'
def decrypt(x)
i = 0
i += 1 until(x == crypt(i))
i
end
def crypt(x)
Zlib::crc32(x.to_s).to_i * 2**4 + 22
end
puts "Write number:"
x = gets.to_i
puts "Encrypting number #{x} ..."
whatever = crypt(x)
puts "Number encrypted to #{whatever}"
puts "Decrypting #{whatever} ..."
res = decrypt(whatever)
puts "Decrypted to #{res}"
if res == x
puts "Number succesfully decrypted!"
else
puts "Number was not decrypted correctly"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment