Saturday, November 22, 2025
HomeLanguageshashlib.shake_128() in Python

hashlib.shake_128() in Python

With the help of hashlib.shake_128() 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_128() method.
Note, We can adjust the length of encrypted data.

Syntax : hashlib.shake_128()

Return : Return the hash code for the string.

Example #1 :
In this example we can see that by using hashlib.shake_128() 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_128() method
gfg = hashlib.shake_128()
gfg.update(b'GeeksForGeeks')
  
print(gfg.digest(10))


Output :

b’b\xfc0\xf2{\x814HG5′

Example #2 :




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


Output :

b’\x80\xa2g\x15>\xcf\xcf\x96\xd60p\x1c\xfc\x00\xfe’

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

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6851 POSTS0 COMMENTS