Recent posts
Tag: #systemrandom · 2 posts
Posted Jan 16
http://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python/23728630#23728630 Using #random.#SystemRandom() instead of just random uses /dev/urandom on *nix machines and #CryptGenRandom() in Windows. These are cryptographically secure #PRNGs. Using random.choice instead of random.SystemRandom().choice in an application that requires a secure PRNG could be potentially devastating, and given the popularity of this question, I bet that mistake has been made many times already. ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(N))
Posted Jan 15
http://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python/23728630#23728630 Using #random.#SystemRandom() instead of just random uses /dev/urandom on *nix machines and #CryptGenRandom() in Windows. These are cryptographically secure #PRNGs. Using random.choice instead of random.SystemRandom().choice in an application that requires a secure PRNG could be potentially devastating, and given the popularity of this question, I bet that mistake has been made many times already. ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(N))