ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* util-sha.lua misbehaving?
@ 2019-02-28 17:46 Pablo Rodriguez
  2019-02-28 21:36 ` Hans Hagen
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez @ 2019-02-28 17:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I have the following sample:

    \startluacode
    function document.capture(cmd, raw)
        local f = assert(io.popen(cmd, 'r'))
        local s = assert(f:read('*a'))
        f:close()
        if raw then return s end
        s = string.gsub(s, '^%s+', '')
        s = string.gsub(s, '%s+$', '')
        s = string.gsub(s, '[\n\r]+', ' ')
        return s
    end

    function document.sha512(file)
        command_output= document.capture("sha512sum -b " .. file)
        context(command_output:sub(0,8))
    end
    \stopluacode

    \def\shafive#1{\ctxlua{document.sha512("#1")}}

    \doif{\luaversion}{5.3}{\ctxlua{require("util-sha")}}

    \def\hashfive#1{%
        \ctxlua{context(
            utilities.sha2.hash512("#1"):sub(0,8))}}

    \def\hashfivefile#1{%
        \ctxlua{context(
            utilities.sha2.hash512(io.loaddata("#1")):sub(0,8))}}

    \def\cB{i-context.pdf}

    \starttext
    \startTEXpage[offset=2em]
    \tt i-context.pdf\ss:
    \doifelse{\luaversion}{5.3}
        {\hashfivefile{\cB}\\
         {\rm text: }\hashfive{\cB}}
        {\shafive{\cB}}
    \stopTEXpage
    \stoptext

Just accidentally, I discovered today (using latest beta from 2019.02.26
20:04) that file hashing may be wrong in ConTeXt. For the sake of
brevity, I only use the 8 first chars.

"sha512sum i-context.pdf" gives c4cc3840. Using luajittex, I get that
result. But using Lua 5.3 (and util-sha.lua), I get 44241e9d.

I don’t know whether my invocation of io.loaddata is wrong, since the
SHA512 for the text "i-context.pdf" is 2ac2778b, which is the same
result as https://duckduckgo.com/?q=sha512+i-context.pdf.

After discovering that io.loaddata is from l-io.lua, I don’t know what I
may be doing wrong.

This is an essential feature for me in ConTeXt, since it is the way of
showing the integrity of the attached files to a PDF document (mainly
digitally signed documents).

Could anyone tell me what I am missing here?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-02-28 17:46 util-sha.lua misbehaving? Pablo Rodriguez
@ 2019-02-28 21:36 ` Hans Hagen
  2019-03-04 15:34   ` luigi scarso
  0 siblings, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2019-02-28 21:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 2/28/2019 6:46 PM, Pablo Rodriguez wrote:
> Dear list,

> Could anyone tell me what I am missing here?
it's bug in the engine ... as a workaround you can uncomment th etop 
lines in util-sha and fall back on pure lua

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-02-28 21:36 ` Hans Hagen
@ 2019-03-04 15:34   ` luigi scarso
  2019-03-04 17:48     ` Pablo Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: luigi scarso @ 2019-03-04 15:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 343 bytes --]

On Thu, Feb 28, 2019 at 10:37 PM Hans Hagen <j.hagen@xs4all.nl> wrote:

> On 2/28/2019 6:46 PM, Pablo Rodriguez wrote:
> > Dear list,
>
> > Could anyone tell me what I am missing here?
> it's bug in the engine ... as a workaround you can uncomment th etop
> lines in util-sha and fall back on pure lua
>
>
it should be fixed  now.


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 782 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 15:34   ` luigi scarso
@ 2019-03-04 17:48     ` Pablo Rodriguez
  2019-03-04 18:12       ` luigi scarso
  2019-03-04 20:20       ` Hans Hagen
  0 siblings, 2 replies; 11+ messages in thread
From: Pablo Rodriguez @ 2019-03-04 17:48 UTC (permalink / raw)
  To: ntg-context

On 3/4/19 4:34 PM, luigi scarso wrote:
> On Thu, Feb 28, 2019 at 10:37 PM Hans Hagen wrote:
> 
>     On 2/28/2019 6:46 PM, Pablo Rodriguez wrote:
>     > Dear list,
> 
>     > Could anyone tell me what I am missing here?
>     it's bug in the engine ... as a workaround you can uncomment th etop
>     lines in util-sha and fall back on pure lua
> 
> it should be fixed  now.

Many thanks for the fix, Luigi.

Sorry for the impatience (the feature is essential for me): when could
be the new version expected a beta or stable version of the ConTeXt Suite?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 17:48     ` Pablo Rodriguez
@ 2019-03-04 18:12       ` luigi scarso
  2019-03-04 18:26         ` Pablo Rodriguez
  2019-03-04 20:20       ` Hans Hagen
  1 sibling, 1 reply; 11+ messages in thread
From: luigi scarso @ 2019-03-04 18:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 879 bytes --]

On Mon, Mar 4, 2019 at 6:48 PM Pablo Rodriguez <oinos@gmx.es> wrote:

> On 3/4/19 4:34 PM, luigi scarso wrote:
> > On Thu, Feb 28, 2019 at 10:37 PM Hans Hagen wrote:
> >
> >     On 2/28/2019 6:46 PM, Pablo Rodriguez wrote:
> >     > Dear list,
> >
> >     > Could anyone tell me what I am missing here?
> >     it's bug in the engine ... as a workaround you can uncomment th etop
> >     lines in util-sha and fall back on pure lua
> >
> > it should be fixed  now.
>
> Many thanks for the fix, Luigi.
>
> Sorry for the impatience (the feature is essential for me): when could
> be the new version expected a beta or stable version of the ConTeXt Suite?
>
> Many thanks for your help,
>
>


r7090 | luigi.scarso@gmail.com | 2019-02-28 23:52:43 +0100 (Thu, 28 Feb
2019) | 1 line

fixed a bug in SHS512 -- trunk

Could be that it's  already in beta --- can you check  ?


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1556 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 18:12       ` luigi scarso
@ 2019-03-04 18:26         ` Pablo Rodriguez
  2019-03-04 18:33           ` luigi scarso
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez @ 2019-03-04 18:26 UTC (permalink / raw)
  To: ntg-context

On 3/4/19 7:12 PM, luigi scarso wrote:
> [...] 
>     Sorry for the impatience (the feature is essential for me): when could
>     be the new version expected a beta or stable version of the ConTeXt
>     Suite?
>  
> r7090 | luigi.scarso@gmail.com <mailto:luigi.scarso@gmail.com> |
> 2019-02-28 23:52:43 +0100 (Thu, 28 Feb 2019) | 1 line
> 
> fixed a bug in SHS512 -- trunk 
> 
> Could be that it's  already in beta --- can you check  ?

I have just checked and it isn’t there.

If it is planned for next beta (or stable), I‘ll wait for it.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 18:26         ` Pablo Rodriguez
@ 2019-03-04 18:33           ` luigi scarso
  2019-03-04 19:40             ` Pablo Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: luigi scarso @ 2019-03-04 18:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 647 bytes --]

On Mon, Mar 4, 2019 at 7:27 PM Pablo Rodriguez <oinos@gmx.es> wrote:

> On 3/4/19 7:12 PM, luigi scarso wrote:
> > [...]
> >     Sorry for the impatience (the feature is essential for me): when
> could
> >     be the new version expected a beta or stable version of the ConTeXt
> >     Suite?
> >
> > r7090 | luigi.scarso@gmail.com <mailto:luigi.scarso@gmail.com> |
> > 2019-02-28 23:52:43 +0100 (Thu, 28 Feb 2019) | 1 line
> >
> > fixed a bug in SHS512 -- trunk
> >
> > Could be that it's  already in beta --- can you check  ?
>
> I have just checked and it isn’t there.
>

 what does
$ luatex --credits
say ?
-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 1273 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 18:33           ` luigi scarso
@ 2019-03-04 19:40             ` Pablo Rodriguez
  2019-03-04 19:56               ` luigi scarso
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez @ 2019-03-04 19:40 UTC (permalink / raw)
  To: ntg-context

On 3/4/19 7:33 PM, luigi scarso wrote:
> [...]
>  what does 
> $ luatex --credits 
> say ?

$ luatex --credits
This is LuaTeX, Version 1.09.2 (TeX Live 2019/dev)
[...]
Development id: 7075

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 19:40             ` Pablo Rodriguez
@ 2019-03-04 19:56               ` luigi scarso
  0 siblings, 0 replies; 11+ messages in thread
From: luigi scarso @ 2019-03-04 19:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 373 bytes --]

On Mon, Mar 4, 2019 at 8:40 PM Pablo Rodriguez <oinos@gmx.es> wrote:

> On 3/4/19 7:33 PM, luigi scarso wrote:
> > [...]
> >  what does
> > $ luatex --credits
> > say ?
>
> $ luatex --credits
> This is LuaTeX, Version 1.09.2 (TeX Live 2019/dev)
> [...]
> Development id: 7075
>

ok , older.
The next one should  be  luatex 1.10 ,  but I dont know exactly when.


-- 
luigi

[-- Attachment #1.2: Type: text/html, Size: 866 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 17:48     ` Pablo Rodriguez
  2019-03-04 18:12       ` luigi scarso
@ 2019-03-04 20:20       ` Hans Hagen
  2019-03-04 20:36         ` Pablo Rodriguez
  1 sibling, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2019-03-04 20:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/4/2019 6:48 PM, Pablo Rodriguez wrote:
> On 3/4/19 4:34 PM, luigi scarso wrote:
>> On Thu, Feb 28, 2019 at 10:37 PM Hans Hagen wrote:
>>
>>      On 2/28/2019 6:46 PM, Pablo Rodriguez wrote:
>>      > Dear list,
>>
>>      > Could anyone tell me what I am missing here?
>>      it's bug in the engine ... as a workaround you can uncomment th etop
>>      lines in util-sha and fall back on pure lua
>>
>> it should be fixed  now.
> 
> Many thanks for the fix, Luigi.
> 
> Sorry for the impatience (the feature is essential for me): when could
> be the new version expected a beta or stable version of the ConTeXt Suite?
we found the issue last week so it should be in the garden soon; but you 
can always use the util-sha.lua method by commenting the test at the top 
which will then force the lua method

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: util-sha.lua misbehaving?
  2019-03-04 20:20       ` Hans Hagen
@ 2019-03-04 20:36         ` Pablo Rodriguez
  0 siblings, 0 replies; 11+ messages in thread
From: Pablo Rodriguez @ 2019-03-04 20:36 UTC (permalink / raw)
  To: ntg-context

On 3/4/19 9:20 PM, Hans Hagen wrote:
> On 3/4/2019 6:48 PM, Pablo Rodriguez wrote:
>> [...]
>> Sorry for the impatience (the feature is essential for me): when could
>> be the new version expected a beta or stable version of the ConTeXt Suite?
> we found the issue last week so it should be in the garden soon; but you 
> can always use the util-sha.lua method by commenting the test at the top 
> which will then force the lua method

If the new version arrivese to the garden soon, I can wait.

Just for the record, forcing the Lua method (many thanks for the advice)
is much slower (unless I’m doing something wrong [≈ ×20 slower]).

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-03-04 20:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 17:46 util-sha.lua misbehaving? Pablo Rodriguez
2019-02-28 21:36 ` Hans Hagen
2019-03-04 15:34   ` luigi scarso
2019-03-04 17:48     ` Pablo Rodriguez
2019-03-04 18:12       ` luigi scarso
2019-03-04 18:26         ` Pablo Rodriguez
2019-03-04 18:33           ` luigi scarso
2019-03-04 19:40             ` Pablo Rodriguez
2019-03-04 19:56               ` luigi scarso
2019-03-04 20:20       ` Hans Hagen
2019-03-04 20:36         ` Pablo Rodriguez

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).