libs/hashes.lua

changeset 422
ff59e4a1a600
parent 421
f35cfdff31b6
child 443
89526c890363
--- a/libs/hashes.lua	Wed Jun 27 19:17:51 2018 +0100
+++ b/libs/hashes.lua	Wed Jun 27 19:18:06 2018 +0100
@@ -1,22 +1,9 @@
 
-local function not_available()
-	error("not available", 2);
+local function not_available(_, method_name)
+	error("Hash method "..method_name.." not available", 2);
 end
 
-local _M = {
-	md5 = not_available;
-	hmac_md5 = not_available;
-
-	sha1 = not_available;
-	hmac_sha1 = not_available;
-	scram_Hi_sha1 = not_available;
-
-	sha256 = not_available;
-	hmac_sha256 = not_available;
-
-	sha512 = not_available;
-	hmac_sha512 = not_available;
-};
+local _M = setmetatable({}, { __index = not_available });
 
 local function with(mod, f)
 	local ok, pkg = pcall(require, mod);

mercurial