mirror of https://github.com/bjc/prosody
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
321 B
19 lines
321 B
local s_char = string.char;
|
|
|
|
local function char_to_hex(c)
|
|
return ("%02x"):format(c:byte())
|
|
end
|
|
|
|
local function hex_to_char(h)
|
|
return s_char(tonumber(h, 16));
|
|
end
|
|
|
|
local function to(s)
|
|
return s:gsub(".", char_to_hex);
|
|
end
|
|
|
|
local function from(s)
|
|
return s:gsub("..", hex_to_char);
|
|
end
|
|
|
|
return { to = to, from = from }
|
|
|