src/sha_dev.js
function finalizeSHA3(remainder, remainderBinLen, processedBinLen, state, blockSize, delimiter, outputLen)
	{
		var i, retVal = [], binaryStringInc = blockSize >>> 5, state_offset = 0,
			remainderIntLen = remainderBinLen >>> 5, temp;


		/* Process as many blocks as possible, some may be here for multiple rounds
		   with SHAKE
		*/
		for (i = 0; i < remainderIntLen && remainderBinLen >= blockSize; i += binaryStringInc)
		{
			state = roundSHA3(remainder.slice(i, i + binaryStringInc), state);
			remainderBinLen -= blockSize;
		}

		remainder = remainder.slice(i);
		remainderBinLen = remainderBinLen % blockSize;

		/* Pad out the remainder to a full block */
		while (remainder.length < binaryStringInc)
		{
			remainder.push(0);
		}

		/* Find the next "empty" byte for the 0x80 and append it via an xor */
		i = remainderBinLen >>> 3;
		remainder[i >> 2] ^= delimiter << (8 * (i % 4));

		remainder[binaryStringInc - 1] ^= 0x80000000;
		state = roundSHA3(remainder, state);

		while (retVal.length * 32 < outputLen)
		{
			temp = state[state_offset % 5][(state_offset / 5) | 0];
			retVal.push(temp.lowOrder);
			if (retVal.length * 32 >= outputLen)
			{
				break;
			}
			retVal.push(temp.highOrder);
			state_offset += 1;

			if (0 === ((state_offset * 64) % blockSize))
			{
				roundSHA3(null, state);
			}
		}

		return retVal;
	}
function finalizeSHA3(remainder, remainderBinLen, processedBinLen, state, blockSize, delimiter, outputLen)
	{
		var i, retVal = [], binaryStringInc = blockSize >>> 5, state_offset = 0,
			remainderIntLen = remainderBinLen >>> 5, temp;


		/* Process as many blocks as possible, some may be here for multiple rounds
		   with SHAKE
		*/
		for (i = 0; i < remainderIntLen && remainderBinLen >= blockSize; i += binaryStringInc)
		{
			state = roundSHA3(remainder.slice(i, i + binaryStringInc), state);
			remainderBinLen -= blockSize;
		}

		remainder = remainder.slice(i);
		remainderBinLen = remainderBinLen % blockSize;

		/* Pad out the remainder to a full block */
		while (remainder.length < binaryStringInc)
		{
			remainder.push(0);
		}

		/* Find the next "empty" byte for the 0x80 and append it via an xor */
		i = remainderBinLen >>> 3;
		remainder[i >> 2] ^= delimiter << (8 * (i % 4));

		remainder[binaryStringInc - 1] ^= 0x80000000;
		state = roundSHA3(remainder, state);

		while (retVal.length * 32 < outputLen)
		{
			temp = state[state_offset % 5][(state_offset / 5) | 0];
			retVal.push(temp.lowOrder);
			if (retVal.length * 32 >= outputLen)
			{
				break;
			}
			retVal.push(temp.highOrder);
			state_offset += 1;

			if (0 === ((state_offset * 64) % blockSize))
			{
				roundSHA3(null, state);
			}
		}

		return retVal;
	}
function finalizeSHA3 ( remainder , remainderBinLen , processedBinLen , state , blockSize , delimiter , outputLen ) { var i , retVal = [ ] , binaryStringInc = blockSize >>> 5 , state_offset = 0 , remainderIntLen = remainderBinLen >>> 5 , temp ; /* Process as many blocks as possible, some may be here for multiple rounds
		   with SHAKE
		*/ for ( i = 0 ; i < remainderIntLen && remainderBinLen >= blockSize ; i += binaryStringInc ) { state = roundSHA3 ( remainder . slice ( i , i + binaryStringInc ) , state ) ; remainderBinLen -= blockSize ; } remainder = remainder . slice ( i ) ; remainderBinLen = remainderBinLen % blockSize ; /* Pad out the remainder to a full block */ while ( remainder . length < binaryStringInc ) { remainder . push ( 0 ) ; } /* Find the next "empty" byte for the 0x80 and append it via an xor */ i = remainderBinLen >>> 3 ; remainder [ i >> 2 ] ^= delimiter << ( 8 * ( i % 4 ) ) ; remainder [ binaryStringInc - 1 ] ^= 0x80000000 ; state = roundSHA3 ( remainder , state ) ; while ( retVal . length * 32 < outputLen ) { temp = state [ state_offset % 5 ] [ ( state_offset / 5 ) | 0 ] ; retVal . push ( temp . lowOrder ) ; if ( retVal . length * 32 >= outputLen ) { break ; } retVal . push ( temp . highOrder ) ; state_offset += 1 ; if ( 0 === ( ( state_offset * 64 ) % blockSize ) ) { roundSHA3 ( null , state ) ; } } return retVal ; }
Finalizes the SHA-3 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<Array<Int_64>>} state The state from a previous round
@param {number} blockSize The block size/rate of the variant in bits
@param {number} delimiter The delimiter value for the variant
@param {number} outputLen The output length for the variant in bits
@return {Array<number>} The array of integers representing the SHA-3
hash of message
Finalizes the SHA - 3 hash