sdc-cryptography
A common source code library for SDC services that use JWE. Apps wishing to use this should add the sdc_cryptography
dependency to their requirements.txt and install with pip.
Basic Use (with pipenv, recommended)
Install requirements
pip install pipenv
make build
Run the unit tests
pipenv run make test
Create a package for deployment
pipenv run make sdist
Basic Use (with activated virtual environment)
Install requirements
These commands will generate a requirements file that pip can use. It doesn't have to be created this way but this is the easiest way.
pip install pipenv
pipenv lock -r --dev > requirements.txt
pip install -r requirements.txt
Run the unit tests
make test
Create a package for deployment
make sdist
Usage
Need to generate a keys.yml file first. Note, this requires a file system to store the file. Then it needs to be loaded, and a key store generated.
generate_keys.py <key_folder_location>
After this has been configured, encrypting and decrypting can be done as in the example below.
secrets_from_file = yaml.safe_load("keys.yml")
validate_required_secrets(secrets_from_file, EXPECTED_SECRETS, KEY_PURPOSE_SUBMISSION)
key_store = KeyStore(secrets_from_file)
# Encrypt JSON (Purpose has a single encryption key in the key store)
from sdc.crypto.encrypter import encrypt
encrypted_json = encrypt(json, key_store, key_purpose)
# Encrypt JSON with encryption service (Purpose has multiple encryption keys in the key store each tagged with a service)
from sdc.crypto.encrypter import encrypt
encrypted_json = encrypt(json, key_store, key_purpose, encryption_for_service="some-service")
# Decrypt UTF8 jwe token
from sdc.crypto.decrypter import decrypt
data_bytes = data.decode('UTF8')
decrypted_json = decrypt(data_bytes, key_store, key_purpose)
PyPi
This repo is available from PyPi at sdc-cryptography
The package is published automatically to PyPi when a tag is created in Github. The configuration for this is in the .travis.yml file.
Metadata
Release files for sdc-cryptography 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sdc-cryptography-1.1.1.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sdc_cryptography-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / sdc-cryptography-1.1.1.tar.gz
| Download URL | sdc-cryptography-1.1.1.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6642ce646c5c0cb0bfbfd4091fff5f9abcbd8c0af3129b977e071af06e66d29e
|
|
BLAKE2b-256 checksum How to use checksums |
7873a54c39098121de9a7a5c36fdea42cffc13732bacc489a5855f3ff51fda26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / sdc_cryptography-1.1.1-py3-none-any.whl
| Download URL | sdc_cryptography-1.1.1-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ee921569c8b82543aba5f1e2591fc96589c0ec0759f979a4c24248d802159c1
|
|
BLAKE2b-256 checksum How to use checksums |
3fee5cbee6a776a914df124c4b0a1aaa1bb290ad9e549b4b025a5fbae55434e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|