who has some example about Base64 Codec
Posted on 2005-11-26 07:54:37 by helloasm
JavaScript code. Quite easy to translate.

function binl2b64(binarray) {
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for (var i = 0; i < binarray.length * 4; i += 3) {
    var triplet = (((binarray >> 8 * ( i  %4)) & 0xFF) << 16)
                | (((binarray >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++) {
      if (i * 8 + j * 6 > binarray.length * 32) str += "="; // RFC compliant padding
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}
Posted on 2005-11-26 07:57:30 by ti_mo_n
Thanks, how about Decode ?
Posted on 2005-11-26 07:59:54 by helloasm