Last active
May 1, 2016 03:45
-
-
Save Lvl4Sword/6edc0dd605a4f457b05d to your computer and use it in GitHub Desktop.
Simple Psuedo-Random Number Generation
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
# Using SystemRandom which is cryptographically secure[1], | |
# this prints out 64 psuedorandom characters for you to use in whatever. | |
# [1]https://docs.python.org/2/library/random.html | |
# "( Use os.urandom() or SystemRandom if you require a | |
# cryptographically secure pseudo-random number generator. )" | |
import random | |
import string | |
import sys | |
version_check = sys.version_info[0] | |
if version_check == 2: | |
letters = string.letters | |
print_this = ''.join(ransys.choice(characters) for x in xrange(64)) | |
else: | |
letters = string.ascii_letters | |
print_this = ''.join(ransys.choice(characters) for x in range(64)) | |
ransys = random.SystemRandom() | |
characters = string.digits + letters + string.punctuation | |
print(print_this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment