From 4f411f177c427c0800ec6b56f5b18df8979b3daa Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Wed, 6 Feb 2019 00:52:38 +0000 Subject: [PATCH] telnet-file: sha256 use hex for convenience; dox --- telnetd/readme.rst | 2 ++ telnetd/telnetd-file.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/telnetd/readme.rst b/telnetd/readme.rst index 38aa441..84f534b 100644 --- a/telnetd/readme.rst +++ b/telnetd/readme.rst @@ -34,6 +34,8 @@ sending a response, is passed in to the function so retrieved. * ``pread`` is the read dual of ``pwrite``; takes a length, an offset, and a file name, and returns a base64-encoded blob. Be careful that length is reasonable, to minimize heap usage. + * ``sha256`` reports the ASCII-fied hex of the file given, useful for + verification of flash contents. * ``cert`` loads a file in its entirety and passes it to ``net.cert.verify``. Be careful, as this can use a lot of heap. diff --git a/telnetd/telnetd-file.lua b/telnetd/telnetd-file.lua index f7d4716..12e9e36 100644 --- a/telnetd/telnetd-file.lua +++ b/telnetd/telnetd-file.lua @@ -17,7 +17,7 @@ return { end , ["sha256"] = function(ll,s) -- compute the hash of a file in flash local fn = string.match(ll,"^%s*([^%s]+)%s*$") - s(crypto.toBase64(crypto.fhash('sha256',fn))) + s(crypto.tohex(crypto.fhash('sha256',fn))) end , ["pread"] = function(ll,s) -- read b64 data from off in fn local len, off, fn = string.match(ll,"^%s*(%d+)%s+(%d+)%s+([^%s]+)%s*$") -- 2.50.1