src/sha_dev.js
function packed2b64(packed, outputLength, bigEndianMod, formatOpts)
	{
		var str = "", length = outputLength / 8, i, j, triplet, int1, int2, shiftModifier,
			b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

		shiftModifier = (bigEndianMod === -1) ? 3 : 0;

		for (i = 0; i < length; i += 3)
		{
			int1 = ((i + 1) < length) ? packed[(i + 1) >>> 2] : 0;
			int2 = ((i + 2) < length) ? packed[(i + 2) >>> 2] : 0;
			triplet = (((packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF) << 16) |
				(((int1 >>> (8 * (shiftModifier + bigEndianMod * ((i + 1) % 4)))) & 0xFF) << 8) |
				((int2 >>> (8 * (shiftModifier + bigEndianMod * ((i + 2) % 4)))) & 0xFF);
			for (j = 0; j < 4; j += 1)
			{
				if (i * 8 + j * 6 <= outputLength)
				{
					str += b64Tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
				}
				else
				{
					str += formatOpts["b64Pad"];
				}
			}
		}
		return str;
	}
function packed2b64(packed, outputLength, bigEndianMod, formatOpts)
	{
		var str = "", length = outputLength / 8, i, j, triplet, int1, int2, shiftModifier,
			b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

		shiftModifier = (bigEndianMod === -1) ? 3 : 0;

		for (i = 0; i < length; i += 3)
		{
			int1 = ((i + 1) < length) ? packed[(i + 1) >>> 2] : 0;
			int2 = ((i + 2) < length) ? packed[(i + 2) >>> 2] : 0;
			triplet = (((packed[i >>> 2] >>> (8 * (shiftModifier + bigEndianMod * (i % 4)))) & 0xFF) << 16) |
				(((int1 >>> (8 * (shiftModifier + bigEndianMod * ((i + 1) % 4)))) & 0xFF) << 8) |
				((int2 >>> (8 * (shiftModifier + bigEndianMod * ((i + 2) % 4)))) & 0xFF);
			for (j = 0; j < 4; j += 1)
			{
				if (i * 8 + j * 6 <= outputLength)
				{
					str += b64Tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
				}
				else
				{
					str += formatOpts["b64Pad"];
				}
			}
		}
		return str;
	}
function packed2b64 ( packed , outputLength , bigEndianMod , formatOpts ) { var str = "" , length = outputLength / 8 , i , j , triplet , int1 , int2 , shiftModifier , b64Tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; shiftModifier = ( bigEndianMod === - 1 ) ? 3 : 0 ; for ( i = 0 ; i < length ; i += 3 ) { int1 = ( ( i + 1 ) < length ) ? packed [ ( i + 1 ) >>> 2 ] : 0 ; int2 = ( ( i + 2 ) < length ) ? packed [ ( i + 2 ) >>> 2 ] : 0 ; triplet = ( ( ( packed [ i >>> 2 ] >>> ( 8 * ( shiftModifier + bigEndianMod * ( i % 4 ) ) ) ) & 0xFF ) << 16 ) | ( ( ( int1 >>> ( 8 * ( shiftModifier + bigEndianMod * ( ( i + 1 ) % 4 ) ) ) ) & 0xFF ) << 8 ) | ( ( int2 >>> ( 8 * ( shiftModifier + bigEndianMod * ( ( i + 2 ) % 4 ) ) ) ) & 0xFF ) ; for ( j = 0 ; j < 4 ; j += 1 ) { if ( i * 8 + j * 6 <= outputLength ) { str += b64Tab . charAt ( ( triplet >>> 6 * ( 3 - j ) ) & 0x3F ) ; } else { str += formatOpts [ "b64Pad" ] ; } } } return str ; }
Convert an array of big-endian words to a base-64 string

@private
@param {Array<number>} packed Array of integers to be converted to
base-64 representation
@param {number} outputLength Length of output in bits
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@param {{outputUpper : boolean, b64Pad : string}} formatOpts Hash list
containing validated output formatting options
@return {string} Base-64 encoded representation of the parameter in
string form
Convert an array of big - endian words to a base - 64 string