'secrets' module in Python.
Devkant Swargiary
Posted on November 23, 2021
The secrets module is useful for generating random numbers which might be used as a password, security tokens etc. for the application. It is used to prevent against modifying cookies, forgery attacks.
-
*Open the terminal and enter the command "python" *
python
-
Import the secrets module
import secrets
-
To generate a random string of characters
secrets.token_hex(16)
-
** The generated 16 digit string **
The above generated secret key could be used in a web application as shown below :
Thanks for reading.
Drop in your suggestions.
Brickbats and Bouquets are welcome.
💖 💪 🙅 🚩
Devkant Swargiary
Posted on November 23, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
learning Celebrating 10,000 Followers on DEV.to – A Journey of Learning and Growth[Must Read]
November 30, 2024