ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Pablo Rodriguez via ntg-context <ntg-context@ntg.nl>
To: Max Chernoff via ntg-context <ntg-context@ntg.nl>
Cc: Pablo Rodriguez <oinos@gmx.es>
Subject: Re: hash for buffer contents
Date: Thu, 22 Sep 2022 17:50:28 +0200	[thread overview]
Message-ID: <e82adee0-9aa5-e463-6bef-2248bca066da@gmx.es> (raw)
In-Reply-To: <f92b8ede0e44df28a1c3d3bc742ef1af3f03f94e.camel@telus.net>

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	other threads:[~2022-09-22 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 16:37 Pablo Rodriguez via ntg-context
2022-09-21 22:26 ` Max Chernoff via ntg-context
2022-09-22 15:50   ` Pablo Rodriguez via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e82adee0-9aa5-e463-6bef-2248bca066da@gmx.es \
    --to=ntg-context@ntg.nl \
    --cc=oinos@gmx.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).