File

util/hex.lua @ 6512:ad159be9e9d7

plugins/muc/muc.lib: Don't expose actor jids to users when anonymous * * * plugins/muc/muc.lib: Allow event listeners to modify actor
author daurnimator <quae@daurnimator.com>
date Tue, 11 Nov 2014 13:08:34 -0500
parent 6384:3f4809d01783
child 6545:ec566d7cd518
line wrap: on
line source

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 }