Skip to main content
Help us improve Python packaging – donate today!

Random password generator

Project Description


passgen is a tool for generating random passwords. It provides both command line utility and underlying python module.


passgen requires Python 2.7 or 3.x.

passgen can be installed with pip:

$ pip install passgen

To install it from source, enter the source distribution directory and run:

$ python install

To install in development mode, run from project directory:

$ pip install --user -e .

Usage (command line)

The most basic usage of passgen command line utility prints 10 random passwords, and is as follows:

$ passgen

passgen accepts several arguments configuring its outcome. Overall synopsis is:

$ passgen [-h] [-l LENGTH] [-n NUMBER] [-p] [--no-digits | --no-letters]
          [--upper | --lower]


-h Display help
-l, --length LENGTH
 Passwords should contain LENGTH characters. Defaults to 12.
-n, --number NUMBER
 Generate NUMBER passwords. Defaults to 10.
-p, --punctuation
 Use punctuation characters
--no-digits Don’t use digits
--no-letters Don’t use letters
--upper Use only upper case letters
--lower Use only lower case letters


Below are some examples of passgen usage.

Output one password:

$ passgen -n 1

Generate one password with eight characters:

$ passgen -n 1 -l 8

Generate one password with all upper case letters:

$ passgen -n 1 --upper

Generate one password with punctuation characters:

$ passgen -n 1 -p

Python module

passgen Python module provides just one function also called passgen.

passgen(length=12, punctuation=False, digits=True, letters=True, case='both')

It returns a random string with length characters. punctuation, digits and letters arguments specify whether punctuation, digits and letters should be used. case specifies letter case and can be one of ‘upper’, ‘lower’ or ‘both’.

For more details, run:

$ python -c 'import passgen; help(passgen.passgen)'


The passgen tests are done using unittest. For running the tests, run from project directory:

$ python tests/ -v


  • Implement generation from format string. For example, ‘ddd’ generating three-digit password.
  • Allow occurance restrictions on punctuation, digits and letters. For example, passgen(min-punctuation=1) returning password with at least one punctuation.



Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
passgen-1.0.1-py2.py3-none-any.whl (6.1 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jan 24, 2016
passgen-1.0.1.tar.gz (4.7 kB) Copy SHA256 hash SHA256 Source None Jan 24, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page