Perl + Digest::MD5, 89 bytes
$_=q(use Digest::MD5 md5_hex;say"MD5 sum of my source is: ",md5_hex"\$_=q($_);eval");eval
No TIO link because Digest::MD5 is not installed on TIO. Note that this requires the language conformance level to be set to 5.10 or higher (-M5.010
; this doesn't carry a byte penalty according to PPCG rules.
Explanation
This is yet another "print a function of the source code" challenge, meaning that it can be trivially solved via a universal quine constructor.
Universal quine constructor
$_=q(…"\$_=q($_);eval");eval
We use the q()
string notation (which nests) to initialize $_
, the "default" variable that Perl uses for missing arguments. Then we eval
with a missing argument, so that the string inside the q()
gets evaluated.
The string inside the q()
is a description of how to create the entire program; we specify the rest of the program literally, then use an unescaped $_
to substitute the whole string in for the inside.
The technique thus creates a string with identical contents to the entire program's source; we could print it to produce a quine. We can also do other things to it first, though, making a universal quine constructor.
The rest of the program
use Digest::MD5 md5_hex;say"MD5 sum of my source is: ",md5_hex
Very simple: import an MD5 builtin, then print the fixed string specified in the question (it's not worth compressing it, I believe that in Perl the decompressor would take up more space than just stating the string literally), and use the MD5 builtin on the string we got via the universal quine constructor.
1@NickT That would be extremely difficult though, I might add. – PyRulez – 2015-07-12T02:28:25.790
1If 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 – 2013-12-19T09:40:23.273