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 project.
Usage
Before using the library, you need to generate a keys.yml file. The key_folder_location should contain the public and private keys that are required by the SDC service using the library. To generate the keys.yml run:
generate_keys.py <key_folder_location>
After this has been configured, encrypting and decrypting can be done as follows:
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 via a GitHub Action when a release tag is created in GitHub. The configuration for this is in the .github/workflows/release.yaml file.
Developing changes
This repository uses poetry. Ensure you have it installed.
To install the dependencies run:
make install
Run linting and the unit tests:
make test
Create a package for deployment:
make build
Metadata
Release files for sdc-cryptography 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sdc_cryptography-1.5.0.tar.gz | 7.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sdc_cryptography-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.5 kB
Release files / sdc_cryptography-1.5.0.tar.gz
| Download URL | sdc_cryptography-1.5.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a2b597fd3b80b68335adfa18560b8af06f9b906ed8ddf20c95bf2e0bbf407be
|
|
BLAKE2b-256 checksum How to use checksums |
a2c936a2d232461604fd470c573226649258ff49e6957cec4157da5b1a48c24c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sdc_cryptography-1.5.0-py3-none-any.whl
| Download URL | sdc_cryptography-1.5.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de843451ac23d3a750a22d4f6cf5c624409c120fce89944f3e8e4dbb0ddaeed9
|
|
BLAKE2b-256 checksum How to use checksums |
5da4871b3c4d81ae6112c08b41cb73ade8ea9bb8cf957b43e78e6f4bb4bf8649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Security for sdc-cryptography 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.