[NTG-context] new hash for buffer (as file)

Max Chernoff mseven at telus.net
Fri Sep 23 06:01:25 CEST 2022

Hi Pablo,

> I mean, to get hash of the file attached to the document, I need to save
> the buffer for "context(utilities.sha2.hash256(io.loaddata(buffer)))".
> But I don’t need to save the buffer to attach it to the PDF document.
> My question is how to define \shabufferfile to avoid \savebuffer (only
> required to get the hash).

The SHA calculation isn't working properly because of a weird newline
issue. Try this:

   just a test
   and another one
       function sha256(str)
           return utilities.sha2.hash256(
               str:gsub(string.char(0x0D), string.char(0x0A))
   \savebuffer[test][temporary-αβγ, prefix=no]
   \attachment[buffer=test, name=\shabuffer{test}, method=hidden]
You can remove the "\savebuffer" and the "\shafile"; I just kept that in to
show that the two hashes are now the same.

-- Max

More information about the ntg-context mailing list