On 9/22/22 00:26, Max Chernoff via ntg-context wrote:
> Hi Pablo,
>
>> Is there any way to get "utilities.sha2.hash512" with the contents of
>> the "abc" buffer?
>
> You can use "buffers.getcontent" or "buffers.raw":

Many thanks for your reply, Max.

This is exactly what I needed.

>    \starttext
>    \startluacode
>        require("util-sha")
>
>        local content = buffers.getcontent("test")
>        -- local content = buffers.raw("test") -- same result
>        local sha512 = utilities.sha2.hash512(content)
>        context(sha512)
>    \stopluacode
>    \stoptext
>
> Depending on what you're trying to do, the "filter" module may be
> helpful here.

I think the following function is just fine for me:

  \startbuffer[test]
  just a test
  \stopbuffer

  \starttext
  \startluacode
    require("util-sha")

    function document.sha512buffer(buffer)
      return utilities.sha2.hash512(buffers.raw(buffer))
    end
  \stopluacode

  \def\shabuffer#1
    {\cldcontext{document.sha512buffer("#1")}}

  \shabuffer{test}

  \stoptext

Many thanks for your help again,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

Reply via email to