]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
add telnetd-file sha256 subcommand
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 4 Aug 2017 20:04:24 +0000 (16:04 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 4 Aug 2017 20:04:24 +0000 (16:04 -0400)
telnetd/telnetd-file.lua

index 9841e70159f031e8999dd614aa22fc09f830280b..4578d6b6bd43ba8541d64c662d85463673e82186 100644 (file)
@@ -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