A little tool to manage secrets
Project description
owned
A little tool to manage secrets.
The package uses the 'owner' library to embed information into byte content (weaving) and store it locally, as well as post the resulting hash to a blockchain for ownership verification. Includes helper functions to verify the posting of hashes on the blockchain.
To install: pip install owned
Main Functionalities
-
store_content(content, ...) -> str
- Optionally weaves metadata into the content (using 'owner') before storage.
- Saves the content in the ~/.config/owned folder under a file name derived from its hash.
- Returns the computed hash string (the 'key').
-
post_hash_to_blockchain(hash_str, provider_uri='http://127.0.0.1:8545', ...)
- Posts the hash to a chosen blockchain via web3.py.
- Returns transaction or logging information.
-
verify_hash_on_blockchain(hash_str, provider_uri='http://127.0.0.1:8545', ...)
- Verifies that a particular hash has been posted on the blockchain.
- Returns information such as block number, transaction details, or a boolean indicating presence.
Helper Functions
- DFLT_HASH: Default hashing function (sha256).
- weave_content(content, extra_info=None): Uses 'owner.HeadWeaver' to weave extra bytes into the content.
- unweave_content(woven_bytes): Recovers content and metadata from woven bytes.
- Additional internal functions for file handling and directory creation.
Examples
>>> from owned import store_content, unweave_content
>>> import os
Store some content (with weaving) and get its hash key.
>>> test_content = b"Hello, doctest!"
>>> key = store_content(test_content, extra_info=b"Extra info", use_weave=True)
Verify the file exists in ~/.config/owned
>>> file_path = os.path.expanduser(f"~/.config/owned/{key}")
>>> assert os.path.isfile(file_path)
Check the length of the SHA256 hash (64 hex chars).
>>> len(key)
64
Read the stored file and unweave the content.
>>> with open(file_path, "rb") as f:
... woven_data = f.read()
>>> original_content = unweave_content(woven_data)
>>> original_content == test_content
True
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
File details
Details for the file owned-0.0.5.tar.gz.
File metadata
- Download URL: owned-0.0.5.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8915f05bf515865c7f156a53b9ddee278ce2d9f8428116b48eeeb85dbf9dbac0
|
|
| MD5 |
95291ca9665bfd86f418fe3b4c2e4e8e
|
|
| BLAKE2b-256 |
91265cb22a115251687eefa28fbfa2677463bfe7b58f16da394d272aa8f5002c
|