Sassy Python Database (and auth) utils
Project description
=====================================
Sassy Python Database(and auth) utils
=====================================
LICENSE: The MIT License
Requirements
============
- Python 3.7 or higher
- pyotp
- qrcode
- setuptools
Usage
=====
import spdb
Database
spdb.Database(path: str) # Create Database object
spdb.Database.create_tables(tables_names: list[str]) -> None # Create tables if not exists
spdb.Database.execute(code) -> str # Execute sqlite3 code
spdb.Database.read_json(name: str, data_id: str) -> dict # Read data by ID as dict
spdb.Database.read_object(Class: class, name: str, data_id: str) -> Class # Read data by ID as object
spdb.Database.write_json(name: str, data_id: str, data: dict) -> None # Write dict by ID
spdb.Database.write_object(name: str, object_id: str, object: Class) -> None # Write object by ID
spdb.Database.delete_dict(name: str, dict_id: str) -> None # Delete dict by ID
spdb.Database.delete_json(name: str, json_id: str) -> None # Delete JSON by ID
spdb.Database.delete_object(name: str, object_id: str) -> None # Delete object by ID
Static:
spdb.Database.object_to_dict(object: Class) -> dict # Convert object into dict
spdb.Database.object_to_json(object: Class) -> dict # Convert object into JSON-compatible dict
spdb.Database.dict_to_object(Class: class, Dict: dict) -> Class # Convert dict into object
spdb.Database.dict_to_json(Dict: dict) -> dict # Convert dict into JSON-compatible dict
spdb.Database.json_to_object(Class: class, JSON: dict) -> Class # Convert JSON into object
TOTP - HOTP
spdb.OTP(token: str=None, app_name: str=None) # Create OTP object
spdb.OTP.now() -> str # Get TOTP code
stdb.OTP.at(index: int) -> str # Get HOTP code
stdb.OTP.time_verify(code: str) -> bool # Verify TOTP code
stdb.OTP.counter_verify(index: int, code: str) -> bool # Verify HOTP code
stdb.OTP.TQR(name: str) -> # Get TOTP QR-code for Google Authentificator
stdb.OTP.HQR(name: str) -> # Get HOTP QR-code for Google Authentificator
Static:
stdb.OTP.generate_token() -> str # Generate random token
Token Generator
stdb.TokenGenerator(code: str) # Create TokenGenerator object
stdb.TokenGenerator.gen(type: str, ID: str, key: str) -> str # Generate token
Static:
stdb.TokenGenerator.parse_token(token: str) -> dict # Parse token
Text Validator
stdb.TextValidator(min: int=4, max: int=64, regexp: str=r'([A-z]|[0-9]|_|-)+') # Create TextValidator object
stdb.TextValidator.check(text: str) -> bool # Check text for conditions
Utils
stdb.utils.sha256(text: str) -> str # Get sha256 from text
stdb.utils.b32encode(text: str) -> str # Encode str into base32 str
stdb.utils.random_text(length: int=None) -> str # Get random text
stdb.utils.random_sha256() -> str # Get random sha256 str
stdb.utils.random_b32 -> str # Get random base32 str
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
spdb-1.0.18.tar.gz
(5.6 kB
view details)
File details
Details for the file spdb-1.0.18.tar.gz.
File metadata
- Download URL: spdb-1.0.18.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfca255c863e7105ef1d0c037f4c2e5b0c8dce6d37e96ef9d665844556a2d0ce
|
|
| MD5 |
6c06cceb6f8d545c5135e31422d5fb1a
|
|
| BLAKE2b-256 |
27597f4bd63a79c7fe407c78a0a5d3a4379fed4c9b6a5d6836cdeb178c372da1
|