# 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
1) 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').
2) 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.
3) 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
```python
>>> from owned import store_content, unweave_content
>>> import os
```
Store some content (with weaving) and get its hash key.
```python
>>> 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
```python
>>> 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).
```python
>>> len(key)
64
```
Read the stored file and unweave the content.
```python
>>> with open(file_path, "rb") as f:
... woven_data = f.read()
>>> original_content = unweave_content(woven_data)
>>> original_content == test_content
True
```
Raw data
{
"_id": null,
"home_page": "https://github.com/thorwhalen/owned",
"name": "owned",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Thor Whalen",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/6b/f2/ee60a1544eedeeedf12d7c5cfef78b4a00e57cd4f904fbb7d2e790871b4d/owned-0.0.4.tar.gz",
"platform": "any",
"description": "# owned\n\nA little tool to manage secrets.\n\nThe package uses the 'owner' library to embed information into byte content (weaving)\nand store it locally, as well as post the resulting hash to a blockchain for ownership\nverification. Includes helper functions to verify the posting of hashes on the blockchain.\n\nTo install:\t```pip install owned```\n\n# Main Functionalities\n\n\n1) store_content(content, ...) -> str\n - Optionally weaves metadata into the content (using 'owner') before storage.\n - Saves the content in the ~/.config/owned folder under a file name derived from its hash.\n - Returns the computed hash string (the 'key').\n\n2) post_hash_to_blockchain(hash_str, provider_uri='http://127.0.0.1:8545', ...)\n - Posts the hash to a chosen blockchain via web3.py.\n - Returns transaction or logging information.\n\n3) verify_hash_on_blockchain(hash_str, provider_uri='http://127.0.0.1:8545', ...)\n - Verifies that a particular hash has been posted on the blockchain.\n - Returns information such as block number, transaction details, or a boolean indicating presence.\n\n## Helper Functions\n\n- DFLT_HASH: Default hashing function (sha256).\n- weave_content(content, extra_info=None): Uses 'owner.HeadWeaver' to weave extra bytes into the content.\n- unweave_content(woven_bytes): Recovers content and metadata from woven bytes.\n- Additional internal functions for file handling and directory creation.\n\n## Examples\n\n```python\n>>> from owned import store_content, unweave_content\n>>> import os\n```\n\nStore some content (with weaving) and get its hash key.\n\n```python\n>>> test_content = b\"Hello, doctest!\"\n>>> key = store_content(test_content, extra_info=b\"Extra info\", use_weave=True)\n```\n\nVerify the file exists in ~/.config/owned\n\n```python\n>>> file_path = os.path.expanduser(f\"~/.config/owned/{key}\")\n>>> assert os.path.isfile(file_path)\n```\n\nCheck the length of the SHA256 hash (64 hex chars).\n\n```python\n>>> len(key)\n64\n```\n\nRead the stored file and unweave the content.\n\n```python\n>>> with open(file_path, \"rb\") as f:\n... woven_data = f.read()\n>>> original_content = unweave_content(woven_data)\n>>> original_content == test_content\nTrue\n```",
"bugtrack_url": null,
"license": "apache-2.0",
"summary": "A little tool to manage secrets",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/thorwhalen/owned"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6bf2ee60a1544eedeeedf12d7c5cfef78b4a00e57cd4f904fbb7d2e790871b4d",
"md5": "c593375c67e9546b67f6be11c08ac950",
"sha256": "32f9e516019b18918cebf556acc2bc68c4ff0d8af94023f89829d7d8c1212149"
},
"downloads": -1,
"filename": "owned-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "c593375c67e9546b67f6be11c08ac950",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9185,
"upload_time": "2025-01-14T13:06:50",
"upload_time_iso_8601": "2025-01-14T13:06:50.348297Z",
"url": "https://files.pythonhosted.org/packages/6b/f2/ee60a1544eedeeedf12d7c5cfef78b4a00e57cd4f904fbb7d2e790871b4d/owned-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-14 13:06:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thorwhalen",
"github_project": "owned",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "owned"
}