Module:Sandbox/Thundercraft5

local p = {}

require('Module:LoadLib')(_G)

local temp = {} local nums = string.split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', '')

for i, letter in ipairs(nums) do	temp[i] = letter end nums = temp

local letters = {} for k, v in pairs(nums) do	letters[v] = k	end

function p.encode(...) local s, key = checkTypeArgs({ 'string', 'number' }, ...) math.randomseed(key) key = tostring(math.random):gsub('^0%.', '%1'):match('%d%d%d%d') local i = 0 return s:gsub('(.)', function(c)		i = i+1		local temp = string.toHex(letters[c]*key)		return string.toHex(letters[c]*key)..(i ~= #s and '_' or '')	end) end

function p.decode(...) local s, key = checkTypeArgs({ 'string', 'number' }, ...) local ret = {} math.randomseed(key) key = tostring(math.random):gsub('^0%.', '%1'):match('%d%d%d%d') s = string.split(s, '_') for i, v in pairs(s) do		s[i] = nums[tonumber(v, 16)/key] end

return table.concat(s, '') end

return p