Skip to content
Luke edited this page Jun 24, 2026 · 3 revisions

Basics

Warning

You need pass-gen v0.4.0 or later.

Getting started

At the top of your script, add the following line (ensuring that passgenapi.py is in the same directory).

import passgenapi

Calling the function

To generate a password, simply call the generatePassword() function. An example is demonstrated below.

import passgenapi

print(passgenapi.generatePassword())

This method uses the default values of upperletters=True, lowerletters=True, numbers=True, symbols=True, length=10


Customisation

Calling the function with custom arguments

To generate a password with custom settings, insert the arguments into the pair of brackets.

import passgenapi

print(passgenapi.generatePassword(symbols=False, length=12))

Advanced

Password entropy

Password entropy is a measure of how unpredictable and difficult a password is to guess or crack through brute-force. In v0.5.0-b3 or later, a password entropy algorithm was added to the API, replacing the password score.

import passgenapi

password, entropy = passgenapi.generatePassword(entropy=True)

Example

import passgenapi

password, entropy = passgenapi.generatePassword(entropy=True)
if entropy < 40:
    print("This is a very weak password :(")
elif entropy < 60:
    print("This is an weak password :(")
elif entropy < 80:
    print("This is a good password :)")
elif entropy < 128:
    print("This is a strong password :)")
else:
    print("This is a future-proof password :)")

Clone this wiki locally