Skip to main content

For use in your UseThatApp Web Apps

Project description

usethatapp

A small utility library for UseThatApp web applications providing helpers to verify signatures and decrypt RSA/OAEP-encrypted messages.

Features

  • Verify PSS/SHA256 signatures
  • Decrypt OAEP/SHA256 encrypted messages
  • Helpers to load RSA keys from files or PEM strings

Install

From PyPI:

pip install usethatapp

Requirements

  • Python >= 3.8
  • cryptography>=46.0.5,<47

Quick usage

The package exposes a simple API in usethatapp.webapps and helpers in usethatapp.encryption.

Example: verify signature and decrypt message from a JSON payload

from usethatapp.webapps import get_version

message_json = '{"signature": "0xdeadbeef...", "contents": "0x..."}'
public_key_path = "./keys/public.pem"
private_key_path = "./keys/private.pem"

version = get_version(message_json, public_key_path, private_key_path)
if version.lower() == 'pro':
    # expose pro features
    print('Pro version detected!')
else:
    # hide pro features
    print('Free version detected.')

Loading keys directly

You can also use the Keys helper from usethatapp.encryption to load keys from PEM strings or files:

from usethatapp.encryption import Keys

pub = Keys.read_public_key_from_file('keys/public.pem')
priv = Keys.read_private_key_from_file('keys/private.pem')

API reference

  • usethatapp.webapps.get_version(message, public_key_path, private_key_path, encoding='utf-8')

    • message: dict or JSON string containing 'signature' and 'contents' (hex strings, optionally prefixed with 0x)
    • public_key_path / private_key_path: paths to PEM key files
    • encoding: attempt to decode decrypted bytes (defaults to 'utf-8')
    • returns: decoded string or raw bytes
  • usethatapp.encryption.decrypt_message(private_key, encrypted_message) -> bytes

  • usethatapp.encryption.verify_signature(public_key, signature, message) -> bool

  • usethatapp.encryption.Keys: convenience class with these methods:

    • read_public_key_from_string(pem_str)
    • read_public_key_from_file(file_path)
    • read_private_key_from_string(pem_str)
    • read_private_key_from_file(file_path)

License

This project is licensed under the MIT License. details.

Links

Contact

For support: support@usethatapp.com

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

usethatapp-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

usethatapp-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file usethatapp-0.2.0.tar.gz.

File metadata

  • Download URL: usethatapp-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for usethatapp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e87fb4dc132a21d993d70bad745337ef978e579889444e3ffb3e11f0745417eb
MD5 bfb9c8ee2832048aac2de87e19290cd4
BLAKE2b-256 d7a6fd72caf3deabf89a7e5ee138420100d5fec9c64cf2d39139d0236d4cdf6d

See more details on using hashes here.

File details

Details for the file usethatapp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: usethatapp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for usethatapp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d375208aefd653afafaeb3d396de9d2001ea47dbd31d806a37319c30b996795
MD5 2b31f0f3f467ae8a93b2131544b05033
BLAKE2b-256 ce2cb821665c377c64b80228357fc37af27b97083ef37ce542fb7b8faa15f751

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