var BASE64={
    enKey: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',

    encode: function(src){
	var str = new Array();
	var ch1, ch2, ch3;
	var pos = 0;

	while (pos + 3 <= src.length) {
	    ch1 = src.charCodeAt(pos++);
	    ch2 = src.charCodeAt(pos++);
	    ch3 = src.charCodeAt(pos++);
	    str.push(this.enKey.charAt(ch1>>2), this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f));
	    str.push(this.enKey.charAt(((ch2<<2)+(ch3>>6))&0x3f), this.enKey.charAt(ch3&0x3f));
	}

        if (pos < src.length){
            ch1 = src.charCodeAt(pos++);
            str.push(this.enKey.charAt(ch1>>2));

            if (pos < src.length){
                ch2 = src.charCodeAt(pos);
                str.push(this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f));
                str.push(this.enKey.charAt(ch2<<2&0x3f), '=');
            }
	    else {
                str.push(this.enKey.charAt(ch1<<4&0x3f), '==');
            }
        }

	return str.join('');
    }
};
