Skip to main content

sdc-cryptography

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

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.3.0
File Size Uploaded
sdc_cryptography-1.3.0.tar.gz 7.0 kB Details

Built distribution (wheel)

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

Total release size: 17.5 kB

Release files / sdc_cryptography-1.3.0.tar.gz

Download URL sdc_cryptography-1.3.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2b89b5414dffd4a498cb5c50351eb3f976e899f521eec990151269b4f6331dbd
BLAKE2b-256 checksum
How to use checksums
724b4e029dc3114d39eba213f895b424608790c3201c8e8426191d4eed2fc0e2
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.3.0-py3-none-any.whl

Download URL sdc_cryptography-1.3.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73c216da9ec62eb8e4dc37db0a03a0821c1ef4c16d88895177feab97110b4b35
BLAKE2b-256 checksum
How to use checksums
0c610a88801c21d1d68e2e31f1ddc10ad619e2275f275ee825a0dfe840afa6fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release history Release notifications | RSS feed

1.4.0

2 release files

This release

1.3.0 This release

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

1.1.2

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