6 local _M = setmetatable({}, { __index = not_available }); |
6 local _M = setmetatable({}, { __index = not_available }); |
7 |
7 |
8 local function with(mod, f) |
8 local function with(mod, f) |
9 local ok, pkg = pcall(require, mod); |
9 local ok, pkg = pcall(require, mod); |
10 if ok then f(pkg); end |
10 if ok then f(pkg); end |
|
11 end |
|
12 |
|
13 local function to_hex(data) |
|
14 return (data:gsub(".", function (c) |
|
15 return ("%02x"):format(c:byte()); |
|
16 end)); |
11 end |
17 end |
12 |
18 |
13 with("util.sha1", function (sha1) |
19 with("util.sha1", function (sha1) |
14 _M.sha1 = sha1.sha1; |
20 _M.sha1 = sha1.sha1; |
15 end); |
21 end); |