Skip to main content

Encoding utility to create Cryptographic Linkage Keys

Project description

CLK Hash

Python implementation of cryptographic longterm key hashing. Supports Python versions 2.7+, 3.5+

This is as described by Rainer Schnell, Tobias Bachteler, and Jörg Reiher in A Novel Error-Tolerant Anonymous Linking Code

codecov Documentation Status Build Status Build Status Requirements Status Downloads

Installation

Install clkhash with all dependencies using pip:

pip install clkhash

If the installation of bitarray fails on Windows you may need to install the appropriate Visual Studio C++ compiler for your version of Python; this is required because the bitarray library compiles a C extension.

Documentation

https://clkhash.readthedocs.io

CLI Tool

After installation of the clkhash library you should have a clkutil program in your path. Alternatively you can use python -m clkhash.cli.

This command line tool can be used to process PII data into Cryptographic Longterm Keys. The tool also has an option for generating fake PII data, and commands to upload hashes to an entity matching service.

$ clkutil generate 1000 fake-pii-out.csv
$ head -n 4  fake-pii-out.csv
INDEX,NAME freetext,DOB YYYY/MM/DD,GENDER M or F
0,Libby Slemmer,1933/09/13,F
1,Garold Staten,1928/11/23,M
2,Yaritza Edman,1972/11/30,F

A schema is required to hash this data. You can retrieve the default schema with

$ clkutil generate-default-schema fake-pii-schema.json

or you can make your own.

To hash this data using its schema, with the shared secret key horse_staple:

$ clkutil hash fake-pii-out.csv horse_staple fake-pii-schema.json /tmp/fake-clk.json
CLK data written to /tmp/fake-clk.json

Note the secret should only be shared with the other entity - and not with anyone carrying out the record linkage. Knowledge of this secret allows reconstruction of the PII from the CLKs.

To use the command line tool without installing clkhash, install the dependencies, then run:

python -m clkhash.cli

clkhash api

To hash a CSV file of entities using the default schema:

from clkhash import clk, randomnames
fake_pii_schema = randomnames.NameList.SCHEMA
clks = clk.generate_clk_from_csv(open('fake-pii-out.csv','r'), 'secret', fake_pii_schema)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clkhash-0.15.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clkhash-0.15.1-py2.py3-none-any.whl (1.7 MB view details)

Uploaded Python 2Python 3

File details

Details for the file clkhash-0.15.1.tar.gz.

File metadata

  • Download URL: clkhash-0.15.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for clkhash-0.15.1.tar.gz
Algorithm Hash digest
SHA256 ae7de42a921cf83441b07dd33715c686f87c24029d26533d7bec5965e2a2fafe
MD5 55c65adf3d0b373c1afd6b3d471ff2ec
BLAKE2b-256 9d3235d3e769392f714fe9eb88c9b9366bf2114b2acf910fe6336345fcc6c596

See more details on using hashes here.

File details

Details for the file clkhash-0.15.1-py2.py3-none-any.whl.

File metadata

  • Download URL: clkhash-0.15.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for clkhash-0.15.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5900b261447ac665a848006de890448effc4d6cbff997a216884d067dc317dce
MD5 6458fa434e21190e111296cdc360613e
BLAKE2b-256 abc0084cc6a0e7a381bb6d509b8e9035fdc4c1d1a193108a81fc13ff76f0c37b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page