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:

Operation Name | Function |
---|---|

Mix Rows(MR) | It is a right multiplication of each row by an 8*8 matrix. |

Substitute Bytes(SB) | It is a simple table lookup and gives nonlinear mapping. |

Add Round Key(AK) | In this the 512 bits of the round key is goes through XOR with 512 bit of current state. |

Shift Columns(SC) | In this except the first column of current state are cyclically downward shifted. |

Hash Value is calculated by using the formula:

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

Install whirlpool library using

pip install whirlpool

**Exmaple 1:**

`# 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) ` |

*chevron_right*

*filter_none*

**Output:**

The hashed value is

95cb4d2d765eb26a922b3ade5a5837a3bc6b18f9a68cec6392f7bf4284c996dd0dd8775dc77964bb9dd92f204d067d3b2c0f36f968607c88cd378ce094438e5a

**Example 2:**

`# 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) ` |

*chevron_right*

*filter_none*

**Output:**

The hashed value is

c3a2aea5a2b487f1a3ee848870dff8ca5af0adcf7eae2a58b40927e87027918c2e9438909c50c2d2bb73f15392c8fde22c94c85a8ef5d8c3b3e86a839909d58b

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- RIPEMD Hash Function
- MD5 hash in Python
- Generating hash id's using uuid3() and uuid5() in Python
- Python | hash() method
- Python 3.6 dictionary implementation using hash tables
- Python Program to print hollow half diamond hash pattern
- Full domain Hashing with variable Hash size in Python
- Python - Call function from another function
- Wand function() function in Python
- Returning a function from a function - Python
- wxPython - GetField() function function in wx.StatusBar
- How to write an empty function in Python - pass statement?
- Function Decorators in Python | Set 1 (Introduction)
- Vulnerability in input() function – Python 2.x
- Function Annotations in Python
- Sorted() function in Python
- Ways to sort list of dictionaries by values in Python - Using lambda function
- Python Numbers | choice() function
- Python | askopenfile() function in Tkinter
- Python | Binding function in Tkinter

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.