# Whirlpool Hash Function in Python

• Last Updated : 13 Jul, 2021

Hash Function is a function which has a huge role in making a System Secure as it converts normal data given to it as an irregular value of fixed length. We can imagine it to be a Shaker in our homes.
When we put data into this function it outputs an irregular value. The Irregular value it outputs is known as “Hash Value”.Hash Values are simply number but are often written in Hexadecimal. Computers manage values as Binary. Hash value is also a data and are often managed in Binary.

#### Whirlpool Hash Function

Whirlpool is a cryptographic hash function created by Vincent Rijmen and Paulo S.L.M. Barreto. It was first published in 2000 and revised in 2001 and 2003. It was derived form square and Advanced Encryption Standard. It is a block cipher hash function and designed after square block cipher. It takes less than 2^256 bits length input and convert it in 512 bit hash. The first version of whirlpool is called Whirlpool-0 and changed to Whirlpool-T after it’s first revision in 2001 . In this version the S-box is changed and become easier to use in hardware. In 2002 a vulnerability was founded in the Whirlpool-0’s diffusion matrix which was removed by changing the matrix and the name was also changed from Whirlpool-T to Whirlpool.
Every block cipher in whirlpool is a 8*8 matrix. The state of the function changes in ever round by using four operations:

Hash Value is calculated by using the formula:

` State = MR*AK*SC*SB(State)`

Install whirlpool library using

`pip install whirlpool`

Example 1:

## Python3

 `# Python program to demonstrate``# whirlpool hash function`  `import` `whirlpool`` ` `string ``=` `b``"GeeksforGeeks"` `h1 ``=` `whirlpool.new(string)``hashed_output ``=` `h1.hexdigest()` `print``(``"The hashed value is"``)``print``(hashed_output)`

Output:

The hashed value is

Example 2:

## Python3

 `# Python program to demonstrate``# whirlpool hash function`  `import` `whirlpool`` ` `string ``=` `b``"GeeksforGeeks"` `h1 ``=` `whirlpool.new(string)``hashed_output ``=` `h1.hexdigest()` `h1.update(b``"Geeks"``)``hashed_output ``=` `h1.hexdigest()` `print``(``"The hashed value is"``)``print``(hashed_output)`

Output:

The hashed value is