Skip to main content

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_dict(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_dict(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

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

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


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

Uploaded Source

File details

Details for the file spdb-1.0.15.tar.gz.

File metadata

  • Download URL: spdb-1.0.15.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for spdb-1.0.15.tar.gz
Algorithm Hash digest
SHA256 cfb4fa56af563d5239d690a64cccb6f5c3ba0863f0ec80ed28df2d4070107e69
MD5 067f29d942a096b644a09bcfaf506667
BLAKE2b-256 63e6d94666839316847115acf4856f56c06afaa86af419d7189812331d8479fc

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