[python] Random string generator

Read the rstr module documentation, there is an advice to use the SystemRandom to generate more secure random string.

from rstr import Rstr
from random import SystemRandom

rgen = Rstr(SystemRandom())

pattern = r"[0-9a-zA-Z]{16}"
pattern1 = r"\S{16}"

print(f"16 long alphanumeric password: {rgen.xeger(pattern)}\n"
      f"16 long all characters passord: {rgen.xeger(pattern1)}")

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s