1 local s_char
= string.char
;
2 local s_format
= string.format;
3 local s_gsub
= string.gsub;
4 local s_lower
= string.lower
;
6 local char_to_hex
= {};
7 local hex_to_char
= {};
12 char
, hex
= s_char(i
), s_format("%02x", i
);
13 char_to_hex
[char
] = hex
;
14 hex_to_char
[hex
] = char
;
19 return (s_gsub(s
, ".", char_to_hex
));
22 local function from(s
)
23 return (s_gsub(s_lower(s
), "%X*(%x%x)%X*", hex_to_char
));
26 return { to
= to
, from
= from
}