development:python:true_random_password_generator

True random password generator in python

import string
import secrets
 
def GenPwd(len):
    allowed_chars = string.ascii_letters + string.digits + string.punctuation
    exclude_chars = {'\n', '\r', '\t', '\x0b', '\x0c'}
    valid_chars = ''.join(char for char in allowed_chars if char not in exclude_chars)
 
    password = ''.join(secrets.choice(valid_chars) for _ in range(len))
    return password
 
print(GenPwd(16))
  • development/python/true_random_password_generator.txt
  • Last modified: 2024/02/05 09:33
  • by tplecko