Created
December 30, 2011 09:41
-
-
Save beny/1539013 to your computer and use it in GitHub Desktop.
h4[K3r5 mini help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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