IWBH_01

json data kompress

Mar 1st, 2021 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //does not reduce size?
  2. var
  3. base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
  4.  
  5. trans64="abcdefghijklmnopqrstuvwxyz()[]{}:;,\"'\\!?*><&$ _-@=#\n0123456789+/"
  6.  
  7. ;
  8.  
  9.  
  10.  
  11. var shrink_64=function(d,s){
  12. //s = shrink (2 bit downsize)
  13. var a,b,m,o="",L=d.length,i=0,r,c,w,z;
  14.  
  15. if(s){a=trans64;b=base64; m=d; }else{b=trans64;a=base64; m=btoa(d); }
  16.  
  17. while(i<L){
  18. z=0;
  19.  
  20. c=m[i];
  21. r=a.indexOf(c);
  22.  
  23.  
  24. if(r<0){
  25.  w=m.substr(0,i)+( "\\u"+(65536|c.charCodeAt(0)).toString(16).substr(1) )+m.substr(i+1); L=w.length; m=w; }else{ o+=b[r];
  26. i++; }
  27. }
  28.  
  29. if(s) o=atob(o);
  30.  
  31. return o;
  32.  
  33. };
Add Comment
Please, Sign In to add comment