forked from jinxinB/lua-AES
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.lua
More file actions
33 lines (26 loc) · 723 Bytes
/
Copy pathutil.lua
File metadata and controls
33 lines (26 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local public={}
local private={}
function private.bytesToHex(bytes)
local hexBytes = "";
for i,byte in ipairs(bytes) do
hexBytes = hexBytes .. string.format("%02x ", byte);
end
return hexBytes;
end
function public.toHexString(data)
local type = type(data);
if (type == "number") then
return string.format("%08x",data);
elseif (type == "table") then
return private.bytesToHex(data);
elseif (type == "string") then
local bytes = {string.byte(data, 1, #data)};
return private.bytesToHex(bytes);
else
return data;
end
end
function public.byteListToString(byteList)
return string.char(table.unpack(byteList))
end
return public