Skip to main content

sdc-cryptography

Build Status Codacy Badge codecov 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.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sdc-cryptography 1.2.1
File Size Uploaded Provenance Actions
sdc_cryptography-1.2.1.tar.gz 19.7 kB Without provenance Details for sdc_cryptography-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sdc-cryptography 1.2.1
File Interpreter ABI Platform Actions
sdc_cryptography-1.2.1-py3-none-any.whl Python 3 none any Details for sdc_cryptography-1.2.1-py3-none-any.whl

Total release size: 33.3 kB

Release files / sdc_cryptography-1.2.1.tar.gz

Download URL sdc_cryptography-1.2.1.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cea2de62e65940efb72bfd3ed677b1e685678521a52eb4c06769ffce506f5847
BLAKE2b-256 checksum
How to use checksums
35f6bac2b2f3c6bf17117b5d17afdbe3ff860f0337f7ac028e48cd0a0bce2a6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / sdc_cryptography-1.2.1-py3-none-any.whl

Download URL sdc_cryptography-1.2.1-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b87da178c0d9c6a8add4e2afbe81139bbb056598af0cda61b52f421fb29451f
BLAKE2b-256 checksum
How to use checksums
5ea2737b383015436c7b41cc684a28985104b396d7f704ce000d042cf14a777c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for sdc-cryptography 1.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page