Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. local a=string.char;local type=type;local select=select;local b=string.sub;local c=table.concat;local d={}local e={}for f=0,255 do local g,h=a(f),a(f,0)d[g]=h;e[h]=g end;local function i(j,k,l,m)if l>=256 then l,m=0,m+1;if m>=256 then k={}m=1 end end;k[j]=a(l,m)l=l+1;return k,l,m end;local function n(j,k,l,m)if l>=256 then l,m=0,m+1;if m>=256 then k={}m=1 end end;k[a(l,m)]=j;l=l+1;return k,l,m end;function decompress(o)if type(o)~="string"then return nil,"string expected, got "..type(o)end;if#o<1 then return nil,"invalid input - not a compressed string"end;local p=b(o,1,1)if p=="u"then return b(o,2)elseif p~="c"then return nil,"invalid input - not a compressed string"end;o=b(o,2)local q=#o;if q<2 then return nil,"invalid input - not a compressed string"end;local k={}local l,m=0,1;local r={}local s=1;local t=b(o,1,2)r[s]=e[t]or k[t]s=s+1;for f=3,q,2 do local u=b(o,f,f+1)local v=e[t]or k[t]if not v then return nil,"could not find last from dict. Invalid input?"end;local w=e[u]or k[u]if w then r[s]=w;s=s+1;k,l,m=n(v..b(w,1,1),k,l,m)else local x=v..b(v,1,1)r[s]=x;s=s+1;k,l,m=n(x,k,l,m)end;t=u end;return c(r)end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement