Skip to main content

a simple and secure password generation library

Project description

Library

This Python package provides a secure and simple password generating library. In order to generate passwords, a class PasswdGenerator was implemented.

All passwords are generated using the standard secrets module which is safe for random number generation.

This PasswdGenerator’s __init__ takes a single argument which is a list of strings from which to choose when generating passwords. The strings will internally be stored as a list frozensets. If unspecified, the default character sets to choose from will be:

  • lowercase letters

  • uppercase letters

  • digits

  • punctuation (!"#$%&\'()*+,-./:;<=>?@[\\]^_\`{|}~')

PasswdGenerator objects are callable and will return a password when called. Two parameters can be given, to the object when calling it, the length of the password to generate and a boolean value telling the object wether not to enforce strict password generation (at least one element from each set). By default, the length of the generated password will be 64 and it will be generated strictly.

These two snippets of code are equivalent:

import pypasswd


passwdgen = pypasswd.PasswdGenerator()
print(passwdgen())

and

import string

import pypasswd

passwdgen = pypasswd.PasswdGenerator(
    string.ascii_lowercase,
    string.ascii_uppercase,
    string.digits,
    string.punctuation
)
print(passwdgen(64, False))

Further documentation can be found here.

Script

As most users will just want to run a script and get a password, a script named pypasswd is shipped with this package. It’s usage is as follows:

usage: pypasswd [-h] [-n N] [-l L] [-c str [str ...]] [-S]

Securely generate a random password.

optional arguments:
  -h, --help            show this help message and exit
  -n N, --number N      number of passwords to generate (default: 1)
  -l L, --length L      size of each password (default: 64)
  -c str [str ...], --charsets str [str ...]
                        strings of characters to choose from (default: lowercase, uppercase, digits and punctuation)
  -S, --no-strict       do not force having at least one character from each character set (default: False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypasswd-1.0.0.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file pypasswd-1.0.0.tar.gz.

File metadata

  • Download URL: pypasswd-1.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for pypasswd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 66e3328d27f197685d0b42cc51eee683514221b59b3924506febcc3ae2d4e9c1
MD5 e7abc537a268b166a42d0b807e446e78
BLAKE2b-256 458f2c28c870abe1004b86efd3cd124170b52983c6091df3698b6087a47c2267

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page