Skip to content

Instantly share code, notes, and snippets.

One-line Random String Generator

Python

CSPRNG (Cryptographically Secure Pseudo-Random Number Generator) functions:

  • os.urandom(n): return a string of n random bytes.
  • random.SystemRandom(): provides random functions that uses os.urandom().

Note: Don't use random module for PRNG for security purposes.