Skip to main content

Library for generating random passwords

Project description

passthon

passthon is a Python library for easily generating random passwords.

Installation

Use the package manager pip to install passthon.

pip install passthon

Usage

First, you need to import the library into your script.

import passthon

The password class

The password class is the main (and the only) class in the passthon module. You will need to directly instantiate it in order to generate passwords.

mypassword = passthon.password(length[,options])

Parameters:

Name Type Description Default
length int The length of the password(s) you want to generate. Doesn't have a default value. You need to specify the length.
lc bool Include lowercase letters. Defaults to True
uc bool Include uppercase letters. Defaults to False
num bool Include numbers. Defaults to True
sym bool Include lowercase characters. Defaults to False

Example: This example corresponds to a 10-character password with only uppercase letters and numbers.
Remember that lc and num parameters are True by default.

mypassword = passthon.password(10, lc=False, uc=True)

Functions

The gen() function

To generate a password based on the previous parameters, you will need to call the gen() function on the instance you previously created.

mypassword.gen()
# This will return a randomly generated password.

The gen_multi() function

Similar to the gen() function, but this one generates more than one password. You will need to specify the amount of passwords you want to generate.

mypassword.gen_multi(amount)
# This will return a certain amount of passwords as a list.

As this function returns a list, you can access each one of the passwords through their index, or even join them in a single string.

Example:

list = mypassword.gen_multi(10)
print(list[3])
# This will print password 4 of 10

string = '-'.join(list)
print(string)
# This will print all 10 passwords separated by a dash (-)

The print() function

This function will directly print a previously generated password. If there's no password generated, it will automatically generate one and print it.

When used in a multi-password context, it prints the list one by one.

mypassword.print()

Contributing

Pull requests are welcome. Also, if you find any problem or error, feel free to contact me. :D

License

MIT

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

passthon-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

passthon-0.0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

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