Skip to main content

Helper functions to pseudonymize data like text, email addresses or license tags.

Project description

gocept.pseudonymize

This package provides helper functions to pseudonymize data like text, integers, email addresses or license tags.

It uses the crypt module for pseudonymization, which means, it is not eligible to pseudonymize long text blocks as the hash generated by crypt is relatively short.

Usage

gocept.pseudonymize provides single functions for pseudonymization of various data types. Each function takes the value, which should be pseudonymized, and a secret, which is passed as a salt to the crypt module. The pseudonymize function return the exact same result, if secret and value do not change:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.text('asdf', 'secret')
'dugD'

This package is tested to be compatible with Python version 2.7 and 3.3.

Detailed Usage Examples

To pseudonymize integer values, gocept.pseudonymize provides the integer function:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.integer(4711, 'secret')
1029

To pseudonymize email addresses, gocept.pseudonymize provides the email function:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.email('mail@gocept.com', 'secret')
'cCSe@7HKlpUc.de'

To pseudonymize IBAN account numbers, gocept.pseudonymize provides the iban function:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.iban('US00123456787650047623', 'secret')
'DE11912270187105821216'

To pseudonymize license tags, gocept.pseudonymize provides the license_tag function:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.license('HAL-AB 123', 'secret')
'Z1Y-YV 784'

To pseudonymize license tags, gocept.pseudonymize provides the phone function:

>>> import gocept.pseudonymize
>>> gocept.pseudonymize.phone('+49 172 34123142', 'secret')
'0511911912178610'

To pseudonymize decimals, gocept.pseudonymize provides the decimal function:

>>> from decimal import Decimal
>>> import gocept.pseudonymize
>>> gocept.pseudonymize.decimal(Decimal('-123.45'), 'secret')
Decimal('-8799.11')

To pseudonymize a date, gocept.pseudonymize provides the date function:

>>> from datetime import date
>>> import gocept.pseudonymize
>>> gocept.pseudonymize.date(date(1983, 1, 11), 'secret')
date(9867, 7, 11)

To pseudonymize a time, gocept.pseudonymize provides the time function:

>>> from datetime import time
>>> import gocept.pseudonymize
>>> gocept.pseudonymize.time(time(23, 59, 59), 'secret')
time(11, 46, 49)

Developing gocept.pseudonymize

Author:

gocept <mail@gocept.com>

Online documentation:

http://pythonhosted.org/gocept.pseudonymize/

PyPI page:

http://pypi.python.org/pypi/gocept.pseudonymize/

Issues:

report by e-mail

Source code:

https://bitbucket.org/gocept/gocept.pseudonymize/

Current change log:

https://bitbucket.org/gocept/gocept.pseudonymize/raw-file/tip/CHANGES.txt

Change log for gocept.pseudonymize

0.1 (2013-09-05)

initial release

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

gocept.pseudonymize-0.1.zip (12.9 kB view hashes)

Uploaded Source

Supported by

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