Used to sign strings.
Project description
String Signer
This module was created to sign strings.
It's only uses building libraries, therefore, it has no external dependency. It is also lightweight and thread-safe, which makes it ideal for use in services and microservices.
The signed string respects the following format: string:hash_algorithm:salt:encoded_signature
Installation
pip install String-Signer
Typical usage example:
Sign session
string_signer = StringSigner("My Secret")
session_id = "b801692b-135f-40ff-8f7e-016dc7748c45"
session = {"user_uuid": "67fa3e17-4672-4036-8184-7fbe4c097439"}
encoded_session = base64.urlsafe_b64encode(json.dumps(session).encode()).decode()
signed_session = string_signer.sign(encoded_session)
redis.set(session_id, signed_session)
Unsign session
string_signer = StringSigner("My Secret")
session_id = "b801692b-135f-40ff-8f7e-016dc7748c45"
signed_session = redis.get(session_id)
encoded_session = string_signer.unsign(signed_session)
session = json.loads(base64.urlsafe_b64decode(encoded_session).decode())
Test Coverage
Name Stmts Miss Cover
-------------------------------------------------------------
src/__init__.py 0 0 100%
src/string_signer/__init__.py 2 0 100%
src/string_signer/exceptions.py 38 0 100%
src/string_signer/main.py 124 0 100%
tests/__init__.py 0 0 100%
tests/unit/__init__.py 0 0 100%
tests/unit/string_signer/__init__.py 0 0 100%
tests/unit/string_signer/test_signer.py 219 0 100%
-------------------------------------------------------------
TOTAL 383 0 100%
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
String Signer-0.1.1.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file String Signer-0.1.1.tar.gz
.
File metadata
- Download URL: String Signer-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbc9093031b49c849ed009f00c63a40e913059f50a0cb29a3a138c84f5071a10 |
|
MD5 | 0ca868ee65dea1b294e4be16df91d79b |
|
BLAKE2b-256 | fb477ec2156301b1ccd234e8c360fbebcfe1b8c81bc59355f1ccce321afbabc6 |
File details
Details for the file String_Signer-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: String_Signer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024457026abdc1ca65a07718c5a244ffcb8f6871f7ab3c49e45d7db1ab4e5ecd |
|
MD5 | 210e67dd986fdf0d027972803f7f6603 |
|
BLAKE2b-256 | b4f06d593ee384501ddfd06df81821fdb2dfc37a075c3c044cc670f04dabfcd1 |