Friday, October 24, 2025
HomeLanguageshashlib.shake_256() in python

hashlib.shake_256() in python

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).’

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS