How to generate good secret keys in python?
How to generate good secret keys in python?
- A secret key should be as random as possible
- Your operating system has ways to generate pretty random stuff based on a cryptographic random generator which can be used to get such a key.
Code :
import os
result=os.urandom(24)
print(result)
- If you run this code, you will get one random string which can be considered as secret key.
- Just copy the key and paste it into your project.
- urandom() method is used to generate a string of size random bytes which is very suitable for cryptographic.
Comments
Post a Comment