Skip to content

Instantly share code, notes, and snippets.

@apettinen
Created November 29, 2017 11:04
Show Gist options
  • Save apettinen/80b6150e034650784973e66801e23452 to your computer and use it in GitHub Desktop.
Save apettinen/80b6150e034650784973e66801e23452 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Will loop until string contains other than strings and digits
# sets of strings and digits
# depends on your local, see locale.getlocale() and locale.setlocale()
# by default this is non-scandic, i.e. basic A-Z,a-z and 0-9
import strings
import os
strings_and_digits = string.letters+string.digits
while True:
gens=os.urandom(33).encode('base64').strip('\n')
if not all(character in strings_and_digits for character in gens):
print("contains other than letters and digits")
print("%s" %gens)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment