Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local str = 'absclkdallskd'
- local d, e = {}, {}
- local function transform(s, st, border, s_len, b_len, c)
- local stream, result, i = '', '', 1
- while i <= #s do
- local a, b = ''
- if st then -- if decoding
- b = string.byte(e[s:sub(i,i)])
- else -- if encoding
- b = s:sub(i,i):byte()
- end
- for o = 0, border do
- a = bit32.extract(b, o)..a
- end
- stream = stream..a
- if #stream == s_len then
- for j = 1, #stream, b_len do
- result = result..string.char(tonumber(stream:sub(j, j+c),2))
- end
- stream = ''
- end
- s, i = s:sub(2), i-1
- end
- return result
- end
- local function encode()
- for i = 1, #str do
- local o = str:sub(i,i)
- if not d[o] then
- d[o] = true
- end
- end
- for i in pairs(d) do
- table.insert(e, i)
- end
- d = nil
- table.sort(e,function(a,b)if a:byte()<b:byte()then return true else return false end end)
- if #e > 128 then
- return nil
- elseif #e <= 128 and #e >= 65 then -- 7
- if string.byte(e[#e]) <= 127 then -- standart
- print(#e, '7s')
- else -- adaptive
- print(#e, '7a')
- end
- elseif #e <= 64 and #e >= 33 then -- 6
- print(#e, '6a')
- elseif #e <= 32 and #e >= 17 then -- 5
- print(#e, '5a')
- elseif #e <= 16 then -- 4
- print(#e, '4a')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement