Comparison

util/sha1.lua @ 486:6416ea3fff86

Fix sha1 support when no binary dependencies available
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Mar 2023 19:06:04 +0000
parent 111:75c73ac9d5a6
child 490:6b2f31da9610
comparison
equal deleted inserted replaced
485:c9a144591649 486:6416ea3fff86
11 local strlen = string.len 11 local strlen = string.len
12 local strchar = string.char 12 local strchar = string.char
13 local strbyte = string.byte 13 local strbyte = string.byte
14 local strsub = string.sub 14 local strsub = string.sub
15 local floor = math.floor 15 local floor = math.floor
16 local bit = require "bit" 16 local bit = bit32 or require "util.bit"
17 local bnot = bit.bnot 17 local bnot = bit.bnot
18 local band = bit.band 18 local band = bit.band
19 local bor = bit.bor 19 local bor = bit.bor
20 local bxor = bit.bxor 20 local bxor = bit.bxor
21 local shl = bit.lshift 21 local shl = bit.lshift
136 return string.char(tonumber(byte, 16)); 136 return string.char(tonumber(byte, 16));
137 end)); 137 end));
138 end 138 end
139 end 139 end
140 140
141 _G.sha1 = {sha1 = sha1}; 141 return {
142 return _G.sha1; 142 sha1 = sha1;
143 };
143 144
144 ------------------------------------------------- 145 -------------------------------------------------
145 ------------------------------------------------- 146 -------------------------------------------------
146 ------------------------------------------------- 147 -------------------------------------------------