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.1.2

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.1.2
File Size Uploaded
sdc-cryptography-1.1.2.tar.gz 19.6 kB Details

Built distribution (wheel)

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

Total release size: 33.2 kB

Release files / sdc-cryptography-1.1.2.tar.gz

Download URL sdc-cryptography-1.1.2.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0abf35a298e2be51379f9867b701524a255357921651ff35ebfe1c6b2eb81f8d
BLAKE2b-256 checksum
How to use checksums
ca681d84cf53d5cdf99ea903572e89794887ecfec2ffbc449e5517c43b9bc8b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

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

Download URL sdc_cryptography-1.1.2-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80e5e9dae84830bbb072f807ca880d186790ece443fddce34dbee7bf2c271a7d
BLAKE2b-256 checksum
How to use checksums
2f7df40cd3c5025284d8313a73113d6189dae90b715ee5e186f4c8110e18e2f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

1.4.0

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.4

2 release files

1.1.3

2 release files

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

2 release files

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