Skip to main content

可配置的密码校验库

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


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.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

passrule-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file passrule-0.1.0.tar.gz.

File metadata

  • Download URL: passrule-0.1.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for passrule-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b38d153ac56d9f808a373764250665afe8d2ef229e2202fdfcf26e55edfa1ba6
MD5 ff4f136409990af684dac274dfe79b36
BLAKE2b-256 4db5c88f119f915a3f69f72e3275f21712c51b98265a6a7bc145b6b444e53fca

See more details on using hashes here.

File details

Details for the file passrule-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: passrule-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for passrule-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 949c0f4ef3728e3f0171c7c603bf1e51b7d63499d327e99814fa413c4b2e3004
MD5 830b0f11d400b93d8f180db4d79608e3
BLAKE2b-256 8cedc0e5709cee22ce1766a8e7898c328e5f73431b11053c5465a351a0e95dc7

See more details on using hashes here.

Supported by

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