21 Août 2014

Base64_Encode and Decode

Category: OOEnky @ 13 h 41 min

Base64_encode.

  1. var base64_encode = function (a,b,c,d,e,f) {
  2.         b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  3.         c="=";
  4.         for(d=f="";e&amp;=3,a.charAt(d++)||(b="=",e);f+=b.charAt(63&amp;c>>++e*2))c=c<<8|a.charCodeAt(d-=!e);
  5.         return f
  6. };
  7.  
  8. coded = base64_encode(scriptletInput);
  9. scriptletResult = coded;

Base64_decode

  1. var base64_decode = function( d,b,c,u,r,q,x ) {
  2.         b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  3.         for(r=q=x="";c=d.charAt(x++);~c&amp;&amp;(u=q%4?u*64+c:c,q++%4)?r+=String.fromCharCode(255&amp;u>>(-2*q&amp;6)):0) c=b.indexOf(c);
  4.         return r;
  5. };
  6.  
  7. decoded = base64_decode(scriptletInput);
  8. scriptletResult = decoded;
  9.  

source

Facebook Twitter Email Linkedin Digg Delicious Reddit Stumbleupon Tumblr

Étiquettes : ,

Laisser une réponse