Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Create a program that prints the MD5 sum of its source in the form:

MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

No cheating - you can't just read the source file and compute its sum. The program must not read any external information.

Of course you can use a MD5 library available for your language.

share|improve this question
If someone manages to collide MD5 (i.e. h = f(h), where f is a crude "salt" for h with all the code garbage that is needed to print), I think they should be allowed to do that. – Nick T Dec 19 '13 at 9:40
@NickT That would be extremely difficult though, I might add. – PyRulez Jul 12 '15 at 2:28
up vote 11 down vote accepted

Python 157 149

r='r=%r;import md5;print "MD5 sum of my source is: "';import md5;print "MD5 sum of my source is: "


MD5 sum of my source is: bb74dfc895c13ab991c4336e75865426

Verification at ideone

share|improve this answer
I'm getting a different md5sum for the source file. – slackwear Nov 9 '12 at 13:38
@slackwear what are you getting? – Matt Nov 9 '12 at 13:39
oh you've edited it again. Right now I get 24ba0a79636297dab8803f571d4e3b44 using md5sum in linux – slackwear Nov 9 '12 at 13:43
@slackwear it looks like you have an extra newline at the end of your source file – Matt Nov 9 '12 at 13:48
I've tried it with and without a trailing newline...maybe i'm missing something here – slackwear Nov 9 '12 at 13:50

Python 2, 91 bytes

s="import md5;print'MD5 sum of my source is: ''s=%r;exec s'%s).hexdigest()";exec s

Using the Python quine variant which doesn't require repeating everything twice. Tested on ideone.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.