Skip to content

Python library for encrypting and decrypting `sindresorhus/conf` files.

License

Notifications You must be signed in to change notification settings

DimmaDont/py-crypt-sindresorhus-conf

Repository files navigation

py-crypt-sindresorhus-conf

This Python library encrypts/decrypts sindresorhus/conf and sindresorhus/electron-store files.

Installation

pip install git+https://github.com/DimmaDont/py-crypt-sindresorhus-conf

Usage example

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"}))
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)