Created
November 9, 2012 12:13
-
-
Save ppetr/4045412 to your computer and use it in GitHub Desktop.
Cryptographic quine - a program that prints out the MD5 sum of its source.
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/env python | |
import hashlib | |
import sys | |
input = ['#!/usr/bin/env python', 'import hashlib', 'import sys', 'try: input', 'except NameError: input = []', 'try: trans', "except NameError: trans = lambda x: 'MD5 sum of my source is: ' \\", ' + hashlib.md5(x).hexdigest()', 'lines = input', 'lines.insert(3, "input = " + repr(input))', "out = '\\n'.join(lines) + '\\n'", 'print trans(out),'] | |
try: input | |
except NameError: input = [] | |
try: trans | |
except NameError: trans = lambda x: 'MD5 sum of my source is: ' \ | |
+ hashlib.md5(x).hexdigest() | |
lines = input | |
lines.insert(3, "input = " + repr(input)) | |
out = '\n'.join(lines) + '\n' | |
print trans(out), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment