* hash for buffer contents
@ 2022-09-21 16:37 Pablo Rodriguez via ntg-context
2022-09-21 22:26 ` Max Chernoff via ntg-context
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-09-21 16:37 UTC (permalink / raw)
To: ConTeXt users; +Cc: Pablo Rodriguez
Dear list,
I have the following sample:
\ctxlua{require("util-sha")}
\starttext
\startbuffer[abc]
samples
\stopbuffer
\cldcontext{utilities.sha2.hash512("buffer-name")}
\stoptext
Is there any way to get "utilities.sha2.hash512" with the contents of
the "abc" buffer?
Many thanks for your help,
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: hash for buffer contents
2022-09-21 16:37 hash for buffer contents 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
0 siblings, 1 reply; 3+ messages in thread
From: Max Chernoff via ntg-context @ 2022-09-21 22:26 UTC (permalink / raw)
To: ntg-context; +Cc: Max Chernoff, oinos
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":
\startbuffer[test]
One
Two
Three
\stopbuffer[test]
\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.
-- Max
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: hash for buffer contents
2022-09-21 22:26 ` Max Chernoff via ntg-context
@ 2022-09-22 15:50 ` Pablo Rodriguez via ntg-context
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-09-22 15:50 UTC (permalink / raw)
To: Max Chernoff via ntg-context; +Cc: Pablo Rodriguez
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-22 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 16:37 hash for buffer contents 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 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).