Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function split(self, sep)
- local sep, fields = sep or ":", {}
- local pattern = string.format("([^%s]+)", sep)
- self:gsub(pattern, function(c) fields[#fields+1]=c end)
- return fields
- end
- function encode(text, scrambler)
- if not scrambler then
- scrambler="There's no scrambler"
- end
- local chars = {}
- for i=1, #text do
- chars[i]=text:sub(i, i)
- end
- key = math.random(10000, 99999)
- for i=1, #scrambler do
- key=key+string.byte(scrambler:sub(i, i))
- end
- local coded=""
- for _, v in pairs(chars) do
- coded=coded..":"..tostring(string.byte(v)*key)
- end
- return coded:sub(2), key
- end
- function decode(text, key)
- numbers = split(text, ":")
- final = ""
- for _, v in pairs(numbers) do
- if tonumber(v)==nil then break end
- final=final..string.char(tonumber(v)/key)
- end
- return final
- end
Advertisement
Add Comment
Please, Sign In to add comment