The Wayback Machine - https://web.archive.org/web/20240118175537/https://www.geeksforgeeks.org/hashlib-shake_256-in-python-2/
Open In App
Related Articles

hashlib.shake_256() in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

With the help of hashlib.shake_256() method, we can convert the normal string in byte format is converted to an encrypted form. Passwords and important files can be converted into hash to protect them with the help of hashlib.shake_256() method.
Note, We can adjust the length of encrypted data.

Syntax : hashlib.shake_256()

Return : Return the hash code for the string.

Example #1 :
In this example we can see that by using hashlib.shake_256() method, we are able to encrypt the byte string or passwords to protect them by using this method.




# import hashlib
import hashlib
  
# Using hashlib.shake_256() method
gfg = hashlib.shake_256()
gfg.update(b'GeeksForGeeks')
  
print(gfg.digest(10))


Output :

b’e\xd6\xdf\x8d\x88\x19\x8d\xe6\x9b<'

Example #2 :




# import hashlib
import hashlib
  
# Using hashlib.shake_256() method
gfg = hashlib.shake_256()
gfg.update(b'xyz@1234_GFG')
  
print(gfg.digest(15))


Output :

b’Mh\xf9X\xd0\xee=\x03\xa5a\xbc\xd0\xbf).’

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 22 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials