How to add MD5 checksum of a tex.file into itself? Here is the code for the primitive \pdfmdfivesum option:

%%%
%%% MD5 number
%%%

\makeatletter
\ifx\pdfmdfivesum\undefined
  \let\pdfmdfivesum\mdfivesum
\fi
\edef\filesum{\pdfmdfivesum file {\jobname}}
\makeatother

\filesum