Dear Sirs,
I wrote a tiny program which calculates the checksum of a file.  It
should provide the the same result as md5sum(1), but it doesn't.

$ ./md5sum.tlu md5sum.tlu 
737d8815930c35e7d112374765dbe01f  md5sum.tlu
$ md5sum md5sum.tlu 
bdab3aa02a33eb91a9e0c1001954a413  md5sum.tlu

This is quite strange, I would expect the same result.

The relevant piece if code is:
----------------------------------------------------------------
file=arg[1]

function md5.hex(s)
  return (string.gsub(md5.sum(s), ".", 
  function (c) return string.format("%02x", string.byte(c)) end))
end

local fh=assert(io.open(file, 'rb'))
content=fh:read("*all")
fh:close()

io.write (md5.hex(content)..'  '..file..'\n')
----------------------------------------------------------------

You can download the complete file from:

  http://tug.org/~kotucha/md5sum.tlu.gz

I'm using md5.sum() in an installer for getnonfreefonts, see:

  http://tug.org/~kotucha/getnonfreefonts

The installer contains the files to install as here-documents.  The
program which inserts the here-documents also creates the checksums.
Since texlua creates checksums which are incompatible with those
created by md5sum(1), I use md5sum.tlu in order to create them.

The installer finally calculates the checksums of the files it
installed.  This works on Unix, but Tomek T. tested it on Windows and
told me that he got checksum mismatches.  For the time beeing, I
commented out the checksum tests.

It's possible that there are problems with line endings.  But I must
admit that I don't remember whether I added the binary flag to the
function install_file(...) before Tomek tested it.  However, the fact
that md5sum.tlu and md5sum(1) provide different results is not what I
expect.

Any idea?

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotu...@web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotu...@web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------
_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to