src/sha_dev.js
function hex2packed(str, existingPacked, existingPackedLen, bigEndianMod)
	{
		var packed, length = str.length, i, num, intOffset, byteOffset,
			existingByteLen, shiftModifier;

		if (0 !== (length % 2))
		{
			throw new Error("String of HEX type must be in byte increments");
		}

		packed = existingPacked || [0];
		existingPackedLen = existingPackedLen || 0;
		existingByteLen = existingPackedLen >>> 3;
		shiftModifier = (bigEndianMod === -1) ? 3 : 0;

		for (i = 0; i < length; i += 2)
		{
			num = parseInt(str.substr(i, 2), 16);
			if (!isNaN(num))
			{
				byteOffset = (i >>> 1) + existingByteLen;
				intOffset = byteOffset >>> 2;
				while (packed.length <= intOffset)
				{
					packed.push(0);
				}
				packed[intOffset] |= num  << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
			}
			else
			{
				throw new Error("String of HEX type contains invalid characters");
			}
		}

		return {"value" : packed, "binLen" : length * 4 + existingPackedLen};
	}
function hex2packed(str, existingPacked, existingPackedLen, bigEndianMod)
	{
		var packed, length = str.length, i, num, intOffset, byteOffset,
			existingByteLen, shiftModifier;

		if (0 !== (length % 2))
		{
			throw new Error("String of HEX type must be in byte increments");
		}

		packed = existingPacked || [0];
		existingPackedLen = existingPackedLen || 0;
		existingByteLen = existingPackedLen >>> 3;
		shiftModifier = (bigEndianMod === -1) ? 3 : 0;

		for (i = 0; i < length; i += 2)
		{
			num = parseInt(str.substr(i, 2), 16);
			if (!isNaN(num))
			{
				byteOffset = (i >>> 1) + existingByteLen;
				intOffset = byteOffset >>> 2;
				while (packed.length <= intOffset)
				{
					packed.push(0);
				}
				packed[intOffset] |= num  << (8 * (shiftModifier + bigEndianMod * (byteOffset % 4)));
			}
			else
			{
				throw new Error("String of HEX type contains invalid characters");
			}
		}

		return {"value" : packed, "binLen" : length * 4 + existingPackedLen};
	}
function hex2packed ( str , existingPacked , existingPackedLen , bigEndianMod ) { var packed , length = str . length , i , num , intOffset , byteOffset , existingByteLen , shiftModifier ; if ( 0 !== ( length % 2 ) ) { throw new Error ( "String of HEX type must be in byte increments" ) ; } packed = existingPacked || [ 0 ] ; existingPackedLen = existingPackedLen || 0 ; existingByteLen = existingPackedLen >>> 3 ; shiftModifier = ( bigEndianMod === - 1 ) ? 3 : 0 ; for ( i = 0 ; i < length ; i += 2 ) { num = parseInt ( str . substr ( i , 2 ) , 16 ) ; if ( ! isNaN ( num ) ) { byteOffset = ( i >>> 1 ) + existingByteLen ; intOffset = byteOffset >>> 2 ; while ( packed . length <= intOffset ) { packed . push ( 0 ) ; } packed [ intOffset ] |= num << ( 8 * ( shiftModifier + bigEndianMod * ( byteOffset % 4 ) ) ) ; } else { throw new Error ( "String of HEX type contains invalid characters" ) ; } } return { "value" : packed , "binLen" : length * 4 + existingPackedLen } ; }
Convert a hex string to an array of big-endian words

@private
@param {string} str String to be converted to binary representation
@param {Array<number>} existingPacked A packed int array of bytes to
append the results to
@param {number} existingPackedLen The number of bits in the existingPacked
array
@param {number} bigEndianMod Modifier for whether hash function is
big or small endian
@return {{value : Array<number>, binLen : number}} Hash list where
"value" contains the output number array and "binLen" is the binary
length of "value"
Convert a hex string to an array of big - endian words