Package: gocept.pseudonymize
Contentsgocept.pseudonymizeUsageDetailed usage examplesRunning testsDeveloping gocept.pseudonymizeChange log3.0 (2023-07-18)2.0.1 (2017-03-22)2.0 (2017-03-20)Backwards incompatible changesFeaturesBug fixes1.1 (2017-03-16)1.0 (2017-03-16)New featuresOther changes0.4.1 (2014-01-14)0.4 (2014-01-14)0.3 (2013-10-09)0.2 (2013-09-06)0.1 (2013-09-05)gocept.pseudonymizeThis package provides helper functions to pseudonymize data like text,
integers, email addresses or license tags.It uses thecrypt.crypt()function for pseudonymization, which means,
longer text blocks require multiplecrypt.crypt()calls.Usagegocept.pseudonymizeprovides single functions for pseudonymization of
various data types. Each function takes thevalue, which should be
pseudonymized, and asecret, which is passed as asaltto thecryptmodule.  Ifsecretandvaluedo not change the
pseudonymize function returns the exact same result when called again:>>> import gocept.pseudonymize
>>> gocept.pseudonymize.text('Here is my little text', 'secret')
'u7YJWz RqdYkfNUFgZii2Y'
>>> gocept.pseudonymize.text('Here is my little text', 'secret')
'u7YJWz RqdYkfNUFgZii2Y'The result has always the same string length as the input. But there is no
guaranty that it is still valid in the domain of the input value. For
example the checksum of the pseudonymized IBAN is not correct.This package is tested to be compatible with Python version 2.7, 3.5 up to 3.8.Detailed usage examplesThere are different pseudonymization function because it is not always
possible to guess the correct one by looking at the input data.For a name use thenamefunction:>>> gocept.pseudonymize.name('Vimladil', 'secret')
'R5lprkud'For an address consisting of street and house number use thestreetfunction:>>> gocept.pseudonymize.street('Testweg 34a', 'secret')
'Kui1xre 723'For an integer value use theintegerfunction:>>> gocept.pseudonymize.integer(4711, 'secret')
2111For a decimal value use thedecimalfunction:>>> from decimal import Decimal
>>> gocept.pseudonymize.decimal(Decimal('-123.45'), 'secret')
Decimal('-8772.11')For an email address use theemailfunction:>>> gocept.pseudonymize.email('mail@gocept.com', 'secret')
'w6ba@ng7ngno.de'For an IBAN account number use theibanfunction:>>> gocept.pseudonymize.iban('US00123456787650047623', 'secret')
'DE10312010975100119998'For a BIC (Business Identifier Code) use thebicfunction:>>> gocept.pseudonymize.bic('PBNKDEFFXXX', 'secret')
'GTY1BPG8PE2'For a license tag of a car use  thelicense_tagfunction:>>> gocept.pseudonymize.license_tag('HAL-AB 123', 'secret')
'PUD-AM 117'For a phone number use thephonefunction:>>> gocept.pseudonymize.phone('+49 172 34123142', 'secret')
'0104118118111676'For a date use thedatefunction:>>> from datetime import date
>>> gocept.pseudonymize.date(date(1983, 1, 11), 'secret')
datetime.date(3021, 1, 18)For a date represented as string use thedatestringfunction. It takes
a format string and keeps zeros date parts as zero.:>>> gocept.pseudonymize.datestring('00/03/2003', 'secret', format='DD/MM/YYYY')
'00/10/7399'For a time value use thetimefunction:>>> from datetime import time
>>> gocept.pseudonymize.time(time(23, 59, 59), 'secret')
datetime.time(13, 11, 49)There are some additional pseudonymizer functions and helper functions in
this package.Running testsThe tests are run usingtox. See its documentation for details.Developing gocept.pseudonymizeAuthor:gocept<mail@gocept.com>Online documentation:http://pythonhosted.org/gocept.pseudonymize/PyPI page:http://pypi.python.org/pypi/gocept.pseudonymize/Issues:https://github.com/gocept/gocept.pseudonymize/issuesSource code:https://github.com/gocept/gocept.pseudonymizeCurrent change log:https://raw.githubusercontent.com/gocept/gocept.pseudonymize/master/CHANGES.rstChange log3.0 (2023-07-18)Drop support for Python 2.7, 3.3, 3.4, 3.5, 3.6.Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.Drop support for PyPy implementation. Thecryptmodule is currently not
working with PyPy3.2.0.1 (2017-03-22)Fixphone()so it does not break if the input is only one character long.
(https://bitbucket.org/gocept/gocept.pseudonymize/issues/1)2.0 (2017-03-20)Backwards incompatible changesA value pseudonymized bytext()no longer contains full stops, they are
converted to spaces. Thus the pseudonymized values may change since version
1.1. (string()now has the former behavior oftext(), see below.)email()now returns its result in all lower case.FeaturesAddstring()pseudonymizer returning a string containing numbers, digits
and full stops. (This is whattext()formerly did.)Bug fixesFix all pseudonymizers: if called with a value which evaluates toFalsethe
value is returned. Butinteger()still pseudonymizes0.Fixemail()so it does not break on an input value which does not contain
an@symbol.1.1 (2017-03-16)Addstreet()pseudonymizer.Addbic()(business identifier code) pseudonymizer.1.0 (2017-03-16)New featuresAddname()pseudonymizer.Other changesClaim support for PyPy.Officially support Python 3.4, 3.5 and 3.6.Bring test coverage to 100 % even for code branches and enforce it for the
future.Re-license from ZPL to MIT.0.4.1 (2014-01-14)Fix handling of usage of glibc2 supported additional encryption algorithms (
signalled using $<id>$<salt>$ as salt).0.4 (2014-01-14)Bugfix:text()pseudonymizer now works as expected for texts longer
than 11 bytes. Previously it returned an 11 byte result for longer texts
ignoring the part after the 11th byte (default behavior of the usedcryptimplementation). (#1296)Fixed handling ofExtended crypt(signalled by starting the salt with an
underscore): Salt is now correctly stripped from result.Caution:This
leads to different pseudonymization results when using a secret starting
with underscore than in version 0.3.0.3 (2013-10-09)Fix tests in documentation + testing documentation now.Add new pseudonymizers:datestring()day()month()year()Caution:Due to changed implementation of thedate()function it
returns different values than in version 0.2.0.2 (2013-09-06)date()does not return pseudonymized years smaller than1900anymore asdatetime.datecan not handle years smaller that1900.0.1 (2013-09-05)Initial release.