Last active
July 3, 2017 17:00
-
-
Save birkin/0f6245dd7eeb24c0f5ad to your computer and use it in GitHub Desktop.
generates key (like django secret-key) string with no possibly-mistaken characters
This file contains 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
# -*- coding: utf-8 -*- | |
import random | |
random = random.SystemRandom() | |
ALLOWED_CHARACTERS = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789' # evil oft-mistaken chars left out | |
LENGTH = 50 # django | |
secret_key = ''.join( random.choice(ALLOWED_CHARACTERS) for i in range(LENGTH) ) | |
print( secret_key ) # outputs, eg, 'PFxkGZSutc82psTD2hyrAxnaFRRu9sArVGqyJTW85kGnZWYsyb' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
credit: from pythonadventures post
other good info: comment by franlu at geoffalday gist