Last active
March 3, 2022 10:57
-
-
Save Colk-tech/b55be9e9de848f403dab8a0d04f8376e to your computer and use it in GitHub Desktop.
A Python script generates secret key of Django with specified length
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils.crypto import get_random_string | |
def get_random_specified_length_secret_key(length: int) -> str: | |
""" | |
Return a random string with specified length usable as a SECRET_KEY setting value. | |
""" | |
chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" | |
return get_random_string(length, chars) | |
if __name__ == "__main__": | |
length: int = 128 | |
print(get_random_specified_length_secret_key(length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment