We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Toy Hash Review

Review the toy hash() function from the last assignment:

func hash(input []byte) [4]byte {
	for i, b := range input {
		rotated := bits.RotateLeft8(uint8(b), 3)
		input[i] = byte(rotated)
	}

	for i, b := range input {
		shifted := b << 2
		input[i] = byte(shifted)
	}

	final := [4]byte{}
	for i, b := range input {
		final[i%len(final)] ^= b
	}

	return final
}