Create and validate strong password
Project description
KeyTitan Password Generator and Validator
The provided Python code defines a class called KeyTitan that serves as a password generator and validator. It generates random passwords that meet certain criteria and validates passwords against specific rules.
KeyTitan Class
The KeyTitan class has the following methods:
__init__(self, length=12)
This is the constructor method for the KeyTitan class. It allows you to initialize an instance of the class with an optional password length, with a default length of 12 characters.
generate_password(self)
This method generates a random password based on specified criteria. The criteria for the generated password are as follows:
- The password must be at least 8 characters long.
- It must include at least one uppercase letter, one lowercase letter, one digit, and one special character.
- The remaining characters are randomly chosen from all character sets.
- The order of characters in the password is randomized.
If the password length is less than 8, a ValueError is raised. Otherwise, a password is generated and returned.
validate_password(self, password)
This method validates a given password against specific criteria, including:
- The password must be at least 8 characters long.
- It must include at least one uppercase letter, one lowercase letter, one digit, and one special character.
If the password meets these criteria, the method returns True. If not, it prints error messages for the specific criteria that the password does not meet and returns False.
Example Usage
The code provides an example of how to use the KeyTitan class:
- An instance of the
KeyTitanclass is created with a specified password length of 10 characters. - A random password is generated using the
generate_passwordmethod and printed to the console. - The generated password is then validated using the
validate_passwordmethod against the same criteria. If the password is valid, it prints "Password is valid." Otherwise, it prints error messages for the criteria that are not met.
Summary
The KeyTitan class provides a simple and customizable way to generate and validate passwords based on specific criteria. It ensures that generated passwords meet security standards by requiring a minimum length and including a mix of character types. The code can be easily integrated into applications or scripts that require secure password generation and validation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keytitan-1.0.0.tar.gz.
File metadata
- Download URL: keytitan-1.0.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5684b0d5b5c00cc25c8e855e833d27907bdbbad5da3ac603432bcb78dabb450
|
|
| MD5 |
e45b0ba4de96c01db9e82215bf391813
|
|
| BLAKE2b-256 |
bef658c7a952a3418ce187729b1c194bb1c2a02cfbdc9723e5c798f9d66256b7
|
File details
Details for the file keytitan-1.0.0-py3-none-any.whl.
File metadata
- Download URL: keytitan-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed63025b1ec2d93431cb934c7fa30f7808ad00d4e96b7b4fa5b6201ead21565
|
|
| MD5 |
6fec46802a59ebc8bbcc1f94c00bf2b8
|
|
| BLAKE2b-256 |
0d8646b16ed9b52e577a726838426d22b0a9e49abf10130de6b6485e96ca0cde
|