src/sha_dev.js
function finalizeSHA1(remainder, remainderBinLen, processedBinLen, H, outputLen)
	{
		var i, appendedMessageLength, offset, totalLen;

		/* The 65 addition is a hack but it works.  The correct number is
		   actually 72 (64 + 8) but the below math fails if
		   remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 = 0,
		   "shorting" the addition is OK. */
		offset = (((remainderBinLen + 65) >>> 9) << 4) + 15;
		while (remainder.length <= offset)
		{
			remainder.push(0);
		}
		/* Append '1' at the end of the binary string */
		remainder[remainderBinLen >>> 5] |= 0x80 << (24 - (remainderBinLen % 32));
		/* Append length of binary string in the position such that the new
		 * length is a multiple of 512.  Logic does not work for even multiples
		 * of 512 but there can never be even multiples of 512. JavaScript
		 * numbers are limited to 2^53 so it's "safe" to treat the totalLen as
		 * a 64-bit integer. */
		totalLen = remainderBinLen + processedBinLen;
		remainder[offset] = totalLen & 0xFFFFFFFF;
		/* Bitwise operators treat the operand as a 32-bit number so need to
		 * use hacky division and round to get access to upper 32-ish bits */
		remainder[offset - 1] = (totalLen / TWO_PWR_32) | 0;

		appendedMessageLength = remainder.length;

		/* This will always be at least 1 full chunk */
		for (i = 0; i < appendedMessageLength; i += 16)
		{
			H = roundSHA1(remainder.slice(i, i + 16), H);
		}

		return H;
	}
function finalizeSHA1(remainder, remainderBinLen, processedBinLen, H, outputLen)
	{
		var i, appendedMessageLength, offset, totalLen;

		/* The 65 addition is a hack but it works.  The correct number is
		   actually 72 (64 + 8) but the below math fails if
		   remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 = 0,
		   "shorting" the addition is OK. */
		offset = (((remainderBinLen + 65) >>> 9) << 4) + 15;
		while (remainder.length <= offset)
		{
			remainder.push(0);
		}
		/* Append '1' at the end of the binary string */
		remainder[remainderBinLen >>> 5] |= 0x80 << (24 - (remainderBinLen % 32));
		/* Append length of binary string in the position such that the new
		 * length is a multiple of 512.  Logic does not work for even multiples
		 * of 512 but there can never be even multiples of 512. JavaScript
		 * numbers are limited to 2^53 so it's "safe" to treat the totalLen as
		 * a 64-bit integer. */
		totalLen = remainderBinLen + processedBinLen;
		remainder[offset] = totalLen & 0xFFFFFFFF;
		/* Bitwise operators treat the operand as a 32-bit number so need to
		 * use hacky division and round to get access to upper 32-ish bits */
		remainder[offset - 1] = (totalLen / TWO_PWR_32) | 0;

		appendedMessageLength = remainder.length;

		/* This will always be at least 1 full chunk */
		for (i = 0; i < appendedMessageLength; i += 16)
		{
			H = roundSHA1(remainder.slice(i, i + 16), H);
		}

		return H;
	}
function finalizeSHA1 ( remainder , remainderBinLen , processedBinLen , H , outputLen ) { var i , appendedMessageLength , offset , totalLen ; /* The 65 addition is a hack but it works.  The correct number is
		   actually 72 (64 + 8) but the below math fails if
		   remainderBinLen + 72 % 512 = 0. Since remainderBinLen % 8 = 0,
		   "shorting" the addition is OK. */ offset = ( ( ( remainderBinLen + 65 ) >>> 9 ) << 4 ) + 15 ; while ( remainder . length <= offset ) { remainder . push ( 0 ) ; } /* Append '1' at the end of the binary string */ remainder [ remainderBinLen >>> 5 ] |= 0x80 << ( 24 - ( remainderBinLen % 32 ) ) ; /* Append length of binary string in the position such that the new
		 * length is a multiple of 512.  Logic does not work for even multiples
		 * of 512 but there can never be even multiples of 512. JavaScript
		 * numbers are limited to 2^53 so it's "safe" to treat the totalLen as
		 * a 64-bit integer. */ totalLen = remainderBinLen + processedBinLen ; remainder [ offset ] = totalLen & 0xFFFFFFFF ; /* Bitwise operators treat the operand as a 32-bit number so need to
		 * use hacky division and round to get access to upper 32-ish bits */ remainder [ offset - 1 ] = ( totalLen / TWO_PWR_32 ) | 0 ; appendedMessageLength = remainder . length ; /* This will always be at least 1 full chunk */ for ( i = 0 ; i < appendedMessageLength ; i += 16 ) { H = roundSHA1 ( remainder . slice ( i , i + 16 ) , H ) ; } return H ; }
Finalizes the SHA-1 hash

@private
@param {Array<number>} remainder Any leftover unprocessed packed ints
that still need to be processed
@param {number} remainderBinLen The number of bits in remainder
@param {number} processedBinLen The number of bits already
processed
@param {Array<number>} H The intermediate H values from a previous
round
@param {number} outputLen Unused for this variant
@return {Array<number>} The array of integers representing the SHA-1
hash of message
Finalizes the SHA - 1 hash