From 425decdf7e9284d15aa726e3ae96b9942fb0e3ea Mon Sep 17 00:00:00 2001 From: IronClawTrem Date: Sun, 16 Feb 2020 03:40:06 +0000 Subject: create tremded branch --- scripts/granger/util.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/granger/util.lua (limited to 'scripts/granger/util.lua') diff --git a/scripts/granger/util.lua b/scripts/granger/util.lua new file mode 100644 index 0000000..77dc476 --- /dev/null +++ b/scripts/granger/util.lua @@ -0,0 +1,28 @@ +-- +-- util.lua +-- various utility functions +-- Copyright (c) 2016 Jeff Kent +-- + +local function hash_file(file, ctx) + local f = io.open(file, "r") + if f == nil then + return nil + end + repeat + local buf = f:read(0x10000) + ctx:update(buf) + until buf == nil + f:close() + return tostring(ctx) +end + +function sha256_file(file) + local ctx = nettle.sha256() + return hash_file(file, ctx) +end + +function md5_file(file) + local ctx = nettle.md5() + return hash_file(file, ctx) +end -- cgit