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
Metadata
Release files for passthon 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| passthon-0.0.1.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| passthon-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / passthon-0.0.1.tar.gz
| Download URL | passthon-0.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
beb2dfb5f5c82e6d5b6dd1e555a934507d51ca65e1b75a08e05e9373f02d4b81
|
|
BLAKE2b-256 checksum How to use checksums |
ad4558da63efef5d724c70567aff858e91da637a72be5d08b5dd4dbe7c660f64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / passthon-0.0.1-py3-none-any.whl
| Download URL | passthon-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a7ac0582a28210c1d788605dd5f570e786cbc0360dcd864f0311b0b73ceec82
|
|
BLAKE2b-256 checksum How to use checksums |
20bd7fe17f64533ec5b6a5bb90ce74e73a81bace30b2922f62c95ea58f7feaa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|