可配置的密码校验库
Project description
PassRule
可配置的密码校验库,支持自定义校验规则。
安装
pip install passrule
使用方法
基本使用
from passrule import PasswordValidator
# 使用默认规则
validator = PasswordValidator()
is_valid, errors = validator.validate("MyPassword123!")
print(is_valid) # True
print(errors) # []
自定义规则
from passrule import PasswordValidator, ValidationRule
# 自定义规则
rule = ValidationRule(
min_length=6,
max_length=20,
require_digits=True,
require_uppercase=False,
require_lowercase=True,
require_special_chars=True,
special_chars="!@#$%"
)
validator = PasswordValidator(rule)
is_valid, errors = validator.validate("password123!")
校验规则
min_length: 最小长度(默认8)max_length: 最大长度(默认无限制)require_digits: 是否需要数字(默认True)require_uppercase: 是否需要大写字母(默认True)require_lowercase: 是否需要小写字母(默认True)require_special_chars: 是否需要特殊字符(默认True)special_chars: 允许的特殊字符(默认"!@#$%^&*()_+-=[]{}|;:,.<>?")
许可证
MIT
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
passrule-0.1.1.tar.gz
(39.5 kB
view details)
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 passrule-0.1.1.tar.gz.
File metadata
- Download URL: passrule-0.1.1.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c02216b72a627e965b2fc6f9ed2400a1ce195a4fc883591e9a548c4787e7e0
|
|
| MD5 |
0379edbbdb5ed70703f6735be0b24a3b
|
|
| BLAKE2b-256 |
c3fc5a4eb99616081c5b23f8d07c0cfd7d677f5c39f0427cd8759b612f65d4f8
|
File details
Details for the file passrule-0.1.1-py3-none-any.whl.
File metadata
- Download URL: passrule-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d501d2dfca0d6305e06009bda3c3e94aaf0a6f784590b6bd40d987533f9e241e
|
|
| MD5 |
60906a5a299f49a9217df5460ee2c087
|
|
| BLAKE2b-256 |
31aa27c10108b5922e26ae2179349e49a39a5562884b3d08735afbe6245adbd4
|