https://github.com/dimmadont/py-crypt-sindresorhus-conf
Python library for encrypting and decrypting `sindresorhus/conf` files.
https://github.com/dimmadont/py-crypt-sindresorhus-conf
conf config electron-store encryption json node-module npm-package sindresorhus storage
Last synced: 2 months ago
JSON representation
Python library for encrypting and decrypting `sindresorhus/conf` files.
- Host: GitHub
- URL: https://github.com/dimmadont/py-crypt-sindresorhus-conf
- Owner: DimmaDont
- License: mit
- Created: 2025-01-10T02:54:19.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-01T01:02:52.000Z (over 1 year ago)
- Last Synced: 2025-03-01T01:23:58.164Z (over 1 year ago)
- Topics: conf, config, electron-store, encryption, json, node-module, npm-package, sindresorhus, storage
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# py-crypt-sindresorhus-conf
This Python library encrypts/decrypts [`sindresorhus/conf`](https://github.com/sindresorhus/conf) and [`sindresorhus/electron-store`](https://github.com/sindresorhus/electron-store) files.
## Installation
```bash
# cryptography
pip install "crypt_sindresorhus_conf[cryptography] @ git+https://github.com/DimmaDont/py-crypt-sindresorhus-conf"
# PyCryptodome
pip install "crypt_sindresorhus_conf[pycryptodome] @ git+https://github.com/DimmaDont/py-crypt-sindresorhus-conf"
```
## Usage example
#### Encryption
```python
import json
import os
from crypt_sindresorhus_conf import CryptSindresorhusConf
key = b"hello there"
iv = os.urandom(16)
conf_crypt = CryptSindresorhusConf(key, iv)
encrypted = conf_crypt.encrypt(json.dumps({"foo": "bar"}))
```
#### Decryption
```python
import json
from crypt_sindresorhus_conf import CryptSindresorhusConf
with open("file.json", "rb") as f:
encrypted = f.read()
key = b"hello there"
iv = encrypted[:16]
conf_crypt = CryptSindresorhusConf(key, iv)
plaintext = conf_crypt.decrypt(encrypted)
data = json.loads(plaintext)
```