sdx-decrypt is a decryption service written in Python. It is a component of the Office of National Statistics (ONS) Survey Data Exchange (SDX) project, which takes an encrypted json payload and transforms it into a number of formats for use within the ONS.
sdx-decrypt uses JSON Web Tokens to decrypt data.
This application presently installs required packages from requirements files:
requirements.txt
: packages for the application, with hashes for all packages: see https://pypi.org/project/hashin/test-requirements.txt
: packages for testing and linting
It's also best to use pyenv
and pyenv-virtualenv
, to build in a virtual environment with the currently recommended version of Python. To install these, see:
- https://github.com/pyenv/pyenv
- https://github.com/pyenv/pyenv-virtualenv
- (Note that the homebrew version of
pyenv
is easiest to install, but can lag behind the latest release of Python.)
Once your virtual environment is set, install the requirements:
$ make build
To test, first run make build
as above, then run:
$ make test
It's also possible to install within a container using docker. From the sdx-decrypt directory:
$ docker build -t sdx-decrypt .
To start sdx-decrypt, just run the server:
$ python server.py
POST /decrypt
- decrypts and returns the data it is sent as JSONGET /healthcheck
- returns a JSON response with a key/value pairs describing the service state
The example below uses the Python library requests to decrypt some data using sdx-decrypt.
import requests
r = requests.post('http://127.0.0.1:5000/decrypt', data=encrypted_data)
decrypted_data = r.text
Compulsory environment variables available for configuration are listed below:
Environment Variable | Description |
---|---|
EQ_PUBLIC_KEY | Location of EQ public key |
PRIVATE_KEY | Location of private key |
PRIVATE_KEY_PASSWORD | Private key password |
Copyright © 2016, Office for National Statistics (https://www.ons.gov.uk)
Released under MIT license, see LICENSE for details.