Skip to main content

A utility library for Python that provides common validation and cryptographic functions for web development.

Project description

PythonWebTools

PythonWebTools is a utility library for Python focused on enhancing your web applications with common utilities and helpers.

Features

  • Email validation
  • CPF and CNPJ validation
  • Password validation
  • Phone number validation
  • Cryptographic utilities

Installation

You can install PythonWebTools using pip. It is recommended to use a virtual environment.

pip install pythonwebtools

Usage

To use PythonWebTools in your application, you need to import the required utilities from the library. Below are examples of how to use each feature.

Email Validation

from pythonwebtools.utils.ValidatorUtils import ValidatorsUtil

validator = ValidatorsUtil()

try:
    is_valid = validator.validate_email("example@email.com")
    print("Email is valid:", is_valid)
except Exception as e:
    print("Invalid email:", str(e))

CPF Validation

from pythonwebtools.utils.ValidatorUtils import ValidatorsUtil

validator = ValidatorsUtil()

cpf = "123.456.789-09"  # Example CPF
is_valid_cpf = validator.validate_cpf(cpf)
print("CPF is valid:", is_valid_cpf)

CNPJ Validation

from pythonwebtools.utils.ValidatorUtils import ValidatorsUtil

validator = ValidatorsUtil()

cnpj = "12.345.678/0001-95"  # Example CNPJ
is_valid_cnpj = validator.validate_cnpj(cnpj)
print("CNPJ is valid:", is_valid_cnpj)

Password Validation

from pythonwebtools.utils.ValidatorUtils import ValidatorsUtil

validator = ValidatorsUtil()

password = "StrongPassword123!"  # Example password
is_valid_password = validator.validate_password(password)
print("Password is valid:", is_valid_password)

Phone Number Validation

from pythonwebtools.utils.ValidatorUtils import ValidatorsUtil

validator = ValidatorsUtil()

phone_number = "5511997027812"  # Example phone number. Only works with Brazilian phone numbers for now
is_valid_phone = validator.phone_number_validator(phone_number)
print("Phone number is valid:", is_valid_phone)

Cryptographic Utilities

For cryptographic functionalities, you can use the cryptography utilities provided in the PythonWebTools library. Below is an example of how to hash a password:

from pythonwebtools.services.HashService import HashService

hash_service = HashService()

password = "my_secure_password"
hashed_password = hash_service.hash_password(password)
print("Hashed password:", hashed_password)

# To verify the password
is_password_correct = hash_service.verify_password(hashed_password, password)
print("Is password correct:", is_password_correct)

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

pythonwebtools-0.1.7.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pythonwebtools-0.1.7-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pythonwebtools-0.1.7.tar.gz.

File metadata

  • Download URL: pythonwebtools-0.1.7.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for pythonwebtools-0.1.7.tar.gz
Algorithm Hash digest
SHA256 5e0e1e13a748ceed3b9da94ead44e4321f624310e9113b224b34a5fe8e6dd53b
MD5 489a169c16370214916598f6f4098c7f
BLAKE2b-256 c74ba49b8a23a89c7b87ad84db1f842d81a3bffd015f570c12b159e08847ce2e

See more details on using hashes here.

File details

Details for the file pythonwebtools-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for pythonwebtools-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d711c0a31b8c6fc99b757cb3561849394e97ff0ee966b49b3940da3a7c6446db
MD5 4b4d2b8c004d8674be538c1667429783
BLAKE2b-256 df5012365dfecd128e382a2b1a852d64634f2c8f5d3c95b71d7492f9a594865e

See more details on using hashes here.

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