From 720c34ce8ddacb0c1ac82d32ae4ebc3e82c25c27 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Fri, 4 Aug 2017 16:04:24 -0400 Subject: [PATCH] add telnetd-file sha256 subcommand --- telnetd/telnetd-file.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/telnetd/telnetd-file.lua b/telnetd/telnetd-file.lua index 9841e70..4578d6b 100644 --- a/telnetd/telnetd-file.lua +++ b/telnetd/telnetd-file.lua @@ -12,6 +12,10 @@ return { , ["compile"] = function(ll,s) local fn = string.match(ll,"^%s*([^%s]+)%s*$"); local r,err = pcall(node.compile,fn); if not r then s("ERR: "..err) end 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))) + 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*$") if fn == nil then s("ERR: Need file"); return end -- 2.50.1