1 if(!dojo._hasResource["dojox.encoding.easy64"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.encoding.easy64"] = true;
3 dojo.provide("dojox.encoding.easy64");
6 var c = function(input, length, result){
7 for(var i = 0; i < length; i += 3){
9 String.fromCharCode((input[i] >>> 2) + 33),
10 String.fromCharCode(((input[i] & 3) << 4) + (input[i + 1] >>> 4) + 33),
11 String.fromCharCode(((input[i + 1] & 15) << 2) + (input[i + 2] >>> 6) + 33),
12 String.fromCharCode((input[i + 2] & 63) + 33)
17 dojox.encoding.easy64.encode = function(input){
18 // summary: encodes input data in easy64 string
19 // input: Array: an array of numbers (0-255) to encode
20 var result = [], reminder = input.length % 3, length = input.length - reminder;
21 c(input, length, result);
23 var t = input.slice(length);
24 while(t.length < 3){ t.push(0); }
26 for(var i = 3; i > reminder; result.pop(), --i);
28 return result.join(""); // String
31 dojox.encoding.easy64.decode = function(input){
32 // summary: decodes the input string back to array of numbers
33 // input: String: the input string to decode
34 var n = input.length, r = [], b = [0, 0, 0, 0], i, j, d;
35 for(i = 0; i < n; i += 4){
36 for(j = 0; j < 4; ++j){ b[j] = input.charCodeAt(i + j) - 33; }
38 for(j = d; j < 4; b[++j] = 0);
40 (b[0] << 2) + (b[1] >>> 4),
41 ((b[1] & 15) << 4) + (b[2] >>> 2),
42 ((b[2] & 3) << 6) + b[3]
44 for(j = d; j < 4; ++j, r.pop());