gocept.pseudonymize


Namegocept.pseudonymize JSON
Version 3.0 PyPI version JSON
download
home_pagehttps://github.com/gocept/gocept.pseudonymize
SummaryPseudonymize data like text, email addresses or license tags.
upload_time2023-07-18 05:44:02
maintainer
docs_urlNone
authorgocept <mail@gocept.com>
requires_python>=3.7
licenseMIT
keywords pseudonymization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            .. contents::

===================
gocept.pseudonymize
===================

.. image:: https://img.shields.io/pypi/v/gocept.pseudonymize.svg
    :target: https://pypi.org/project/gocept.pseudonymize/

.. image:: https://img.shields.io/pypi/pyversions/gocept.pseudonymize.svg
    :target: https://pypi.org/project/gocept.pseudonymize/

.. image:: https://github.com/gocept/gocept.pseudonymize/workflows/tests/badge.svg
    :target: https://github.com/gocept/gocept.pseudonymize/actions?query=workflow%3Atests

.. image:: https://coveralls.io/repos/github/gocept/gocept.pseudonymize/badge.svg?branch=master
    :target: https://coveralls.io/github/gocept/gocept.pseudonymize?branch=master


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

It uses the ``crypt.crypt()`` function for pseudonymization, which means,
longer text blocks require multiple ``crypt.crypt()`` calls.


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.  If ``secret`` and ``value`` do 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 examples
=======================

There 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 the ``name`` function::

    >>> gocept.pseudonymize.name('Vimladil', 'secret')
    'R5lprkud'

* For an address consisting of street and house number use the ``street``
  function::

    >>> gocept.pseudonymize.street('Testweg 34a', 'secret')
    'Kui1xre 723'

* For an integer value use the ``integer`` function::

    >>> gocept.pseudonymize.integer(4711, 'secret')
    2111

* For a decimal value use the ``decimal`` function::

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

* For an email address use the ``email`` function::

    >>> gocept.pseudonymize.email('mail@gocept.com', 'secret')
    'w6ba@ng7ngno.de'

* For an IBAN account number use the ``iban`` function::

    >>> gocept.pseudonymize.iban('US00123456787650047623', 'secret')
    'DE10312010975100119998'

* For a BIC (Business Identifier Code) use the ``bic`` function::

    >>> gocept.pseudonymize.bic('PBNKDEFFXXX', 'secret')
    'GTY1BPG8PE2'

* For a license tag of a car use  the ``license_tag`` function::

    >>> gocept.pseudonymize.license_tag('HAL-AB 123', 'secret')
    'PUD-AM 117'

* For a phone number use the ``phone`` function::

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

* For a date use the ``date`` function::

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

* For a date represented as string use the ``datestring`` function. 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 the ``time`` function::

    >>> 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 tests
=============

The tests are run using tox_. See its documentation for details.

.. _tox : https://pypi.python.org/pypi/tox

==============================
Developing gocept.pseudonymize
==============================

:Author:
    `gocept <http://gocept.com/>`_ <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/issues

:Source code:
    https://github.com/gocept/gocept.pseudonymize

:Current change log:
    https://raw.githubusercontent.com/gocept/gocept.pseudonymize/master/CHANGES.rst


==========
Change log
==========

3.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. The ``crypt`` module is currently not
  working with PyPy3.


2.0.1 (2017-03-22)
==================

- Fix ``phone()`` 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 changes
------------------------------

- A value pseudonymized by ``text()`` 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 of ``text()``, see below.)

- ``email()``  now returns its result in all lower case.

Features
--------

- Add ``string()`` pseudonymizer returning a string containing numbers, digits
  and full stops. (This is what ``text()`` formerly did.)

Bug fixes
---------

- Fix all pseudonymizers: if called with a value which evaluates to `False` the
  value is returned. But ``integer()`` still pseudonymizes `0`.

- Fix ``email()`` so it does not break on an input value which does not contain
  an `@` symbol.


1.1 (2017-03-16)
================

- Add ``street()`` pseudonymizer.

- Add ``bic()`` (business identifier code) pseudonymizer.


1.0 (2017-03-16)
================

New features
------------

- Add ``name()`` pseudonymizer.

Other changes
-------------

- Claim 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 used
  ``crypt`` implementation). (#1296)

- Fixed handling of `Extended 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 the ``date()`` function it
  returns different values than in version 0.2.


0.2 (2013-09-06)
================

- ``date()`` does not return pseudonymized years smaller than `1900` anymore as
  ``datetime.date`` can not handle years smaller that `1900`.


0.1 (2013-09-05)
================

- Initial release.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gocept/gocept.pseudonymize",
    "name": "gocept.pseudonymize",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "Pseudonymization",
    "author": "gocept <mail@gocept.com>",
    "author_email": "mail@gocept.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/8f/76e11f19854b85972ea5952b569ee1fffba60f3f67d7b494f823b3fb6854/gocept.pseudonymize-3.0.tar.gz",
    "platform": null,
    "description": ".. contents::\n\n===================\ngocept.pseudonymize\n===================\n\n.. image:: https://img.shields.io/pypi/v/gocept.pseudonymize.svg\n    :target: https://pypi.org/project/gocept.pseudonymize/\n\n.. image:: https://img.shields.io/pypi/pyversions/gocept.pseudonymize.svg\n    :target: https://pypi.org/project/gocept.pseudonymize/\n\n.. image:: https://github.com/gocept/gocept.pseudonymize/workflows/tests/badge.svg\n    :target: https://github.com/gocept/gocept.pseudonymize/actions?query=workflow%3Atests\n\n.. image:: https://coveralls.io/repos/github/gocept/gocept.pseudonymize/badge.svg?branch=master\n    :target: https://coveralls.io/github/gocept/gocept.pseudonymize?branch=master\n\n\nThis package provides helper functions to pseudonymize data like text,\nintegers, email addresses or license tags.\n\nIt uses the ``crypt.crypt()`` function for pseudonymization, which means,\nlonger text blocks require multiple ``crypt.crypt()`` calls.\n\n\nUsage\n=====\n\n``gocept.pseudonymize`` provides single functions for pseudonymization of\nvarious data types. Each function takes the ``value``, which should be\npseudonymized, and a ``secret``, which is passed as a ``salt`` to the\n``crypt`` module.  If ``secret`` and ``value`` do not change the\npseudonymize function returns the exact same result when called again::\n\n    >>> import gocept.pseudonymize\n    >>> gocept.pseudonymize.text('Here is my little text', 'secret')\n    'u7YJWz RqdYkfNUFgZii2Y'\n    >>> gocept.pseudonymize.text('Here is my little text', 'secret')\n    'u7YJWz RqdYkfNUFgZii2Y'\n\nThe result has always the same string length as the input. But there is no\nguaranty that it is still valid in the domain of the input value. For\nexample the checksum of the pseudonymized IBAN is not correct.\n\n\nThis package is tested to be compatible with Python version 2.7, 3.5 up to 3.8.\n\n\nDetailed usage examples\n=======================\n\nThere are different pseudonymization function because it is not always\npossible to guess the correct one by looking at the input data.\n\n* For a name use the ``name`` function::\n\n    >>> gocept.pseudonymize.name('Vimladil', 'secret')\n    'R5lprkud'\n\n* For an address consisting of street and house number use the ``street``\n  function::\n\n    >>> gocept.pseudonymize.street('Testweg 34a', 'secret')\n    'Kui1xre 723'\n\n* For an integer value use the ``integer`` function::\n\n    >>> gocept.pseudonymize.integer(4711, 'secret')\n    2111\n\n* For a decimal value use the ``decimal`` function::\n\n    >>> from decimal import Decimal\n    >>> gocept.pseudonymize.decimal(Decimal('-123.45'), 'secret')\n    Decimal('-8772.11')\n\n* For an email address use the ``email`` function::\n\n    >>> gocept.pseudonymize.email('mail@gocept.com', 'secret')\n    'w6ba@ng7ngno.de'\n\n* For an IBAN account number use the ``iban`` function::\n\n    >>> gocept.pseudonymize.iban('US00123456787650047623', 'secret')\n    'DE10312010975100119998'\n\n* For a BIC (Business Identifier Code) use the ``bic`` function::\n\n    >>> gocept.pseudonymize.bic('PBNKDEFFXXX', 'secret')\n    'GTY1BPG8PE2'\n\n* For a license tag of a car use  the ``license_tag`` function::\n\n    >>> gocept.pseudonymize.license_tag('HAL-AB 123', 'secret')\n    'PUD-AM 117'\n\n* For a phone number use the ``phone`` function::\n\n    >>> gocept.pseudonymize.phone('+49 172 34123142', 'secret')\n    '0104118118111676'\n\n* For a date use the ``date`` function::\n\n    >>> from datetime import date\n    >>> gocept.pseudonymize.date(date(1983, 1, 11), 'secret')\n    datetime.date(3021, 1, 18)\n\n* For a date represented as string use the ``datestring`` function. It takes\n  a format string and keeps zeros date parts as zero.::\n\n    >>> gocept.pseudonymize.datestring('00/03/2003', 'secret', format='DD/MM/YYYY')\n    '00/10/7399'\n\n* For a time value use the ``time`` function::\n\n    >>> from datetime import time\n    >>> gocept.pseudonymize.time(time(23, 59, 59), 'secret')\n    datetime.time(13, 11, 49)\n\nThere are some additional pseudonymizer functions and helper functions in\nthis package.\n\n\n=============\nRunning tests\n=============\n\nThe tests are run using tox_. See its documentation for details.\n\n.. _tox : https://pypi.python.org/pypi/tox\n\n==============================\nDeveloping gocept.pseudonymize\n==============================\n\n:Author:\n    `gocept <http://gocept.com/>`_ <mail@gocept.com>\n\n:Online documentation:\n    http://pythonhosted.org/gocept.pseudonymize/\n\n:PyPI page:\n    http://pypi.python.org/pypi/gocept.pseudonymize/\n\n:Issues:\n    https://github.com/gocept/gocept.pseudonymize/issues\n\n:Source code:\n    https://github.com/gocept/gocept.pseudonymize\n\n:Current change log:\n    https://raw.githubusercontent.com/gocept/gocept.pseudonymize/master/CHANGES.rst\n\n\n==========\nChange log\n==========\n\n3.0 (2023-07-18)\n================\n\n- Drop support for Python 2.7, 3.3, 3.4, 3.5, 3.6.\n\n- Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.\n\n- Drop support for PyPy implementation. The ``crypt`` module is currently not\n  working with PyPy3.\n\n\n2.0.1 (2017-03-22)\n==================\n\n- Fix ``phone()`` so it does not break if the input is only one character long.\n  (https://bitbucket.org/gocept/gocept.pseudonymize/issues/1)\n\n\n2.0 (2017-03-20)\n================\n\nBackwards incompatible changes\n------------------------------\n\n- A value pseudonymized by ``text()`` no longer contains full stops, they are\n  converted to spaces. Thus the pseudonymized values may change since version\n  1.1. (``string()`` now has the former behavior of ``text()``, see below.)\n\n- ``email()``  now returns its result in all lower case.\n\nFeatures\n--------\n\n- Add ``string()`` pseudonymizer returning a string containing numbers, digits\n  and full stops. (This is what ``text()`` formerly did.)\n\nBug fixes\n---------\n\n- Fix all pseudonymizers: if called with a value which evaluates to `False` the\n  value is returned. But ``integer()`` still pseudonymizes `0`.\n\n- Fix ``email()`` so it does not break on an input value which does not contain\n  an `@` symbol.\n\n\n1.1 (2017-03-16)\n================\n\n- Add ``street()`` pseudonymizer.\n\n- Add ``bic()`` (business identifier code) pseudonymizer.\n\n\n1.0 (2017-03-16)\n================\n\nNew features\n------------\n\n- Add ``name()`` pseudonymizer.\n\nOther changes\n-------------\n\n- Claim support for PyPy.\n\n- Officially support Python 3.4, 3.5 and 3.6.\n\n- Bring test coverage to 100 % even for code branches and enforce it for the\n  future.\n\n- Re-license from ZPL to MIT.\n\n\n0.4.1 (2014-01-14)\n==================\n\n- Fix handling of usage of glibc2 supported additional encryption algorithms (\n  signalled using $<id>$<salt>$ as salt).\n\n\n0.4 (2014-01-14)\n================\n\n- Bugfix: ``text()`` pseudonymizer now works as expected for texts longer\n  than 11 bytes. Previously it returned an 11 byte result for longer texts\n  ignoring the part after the 11th byte (default behavior of the used\n  ``crypt`` implementation). (#1296)\n\n- Fixed handling of `Extended crypt` (signalled by starting the salt with an\n  underscore): Salt is now correctly stripped from result. **Caution:** This\n  leads to different pseudonymization results when using a secret starting\n  with underscore than in version 0.3.\n\n\n0.3 (2013-10-09)\n================\n\n- Fix tests in documentation + testing documentation now.\n\n- Add new pseudonymizers:\n\n  - ``datestring()``\n\n  - ``day()``\n\n  - ``month()``\n\n  - ``year()``\n\n- **Caution:** Due to changed implementation of the ``date()`` function it\n  returns different values than in version 0.2.\n\n\n0.2 (2013-09-06)\n================\n\n- ``date()`` does not return pseudonymized years smaller than `1900` anymore as\n  ``datetime.date`` can not handle years smaller that `1900`.\n\n\n0.1 (2013-09-05)\n================\n\n- Initial release.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pseudonymize data like text, email addresses or license tags.",
    "version": "3.0",
    "project_urls": {
        "Homepage": "https://github.com/gocept/gocept.pseudonymize"
    },
    "split_keywords": [
        "pseudonymization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "262f191351ae65bb910c9aee591925ae521ea479a1200aeaf2482446eef4a1d3",
                "md5": "b51416870589f9597d447487fdcb0e8d",
                "sha256": "ce7c7077837cdecd749c2b642fab28b4aaeb234aa649264bfa8b3d260c23c7af"
            },
            "downloads": -1,
            "filename": "gocept.pseudonymize-3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b51416870589f9597d447487fdcb0e8d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 10678,
            "upload_time": "2023-07-18T05:44:01",
            "upload_time_iso_8601": "2023-07-18T05:44:01.868670Z",
            "url": "https://files.pythonhosted.org/packages/26/2f/191351ae65bb910c9aee591925ae521ea479a1200aeaf2482446eef4a1d3/gocept.pseudonymize-3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e78f76e11f19854b85972ea5952b569ee1fffba60f3f67d7b494f823b3fb6854",
                "md5": "e7d561669133060f335eab19a227f962",
                "sha256": "2bae9a004cdeb6d286d0d423f4af72960686bbfaecbaa7ff83232b243e1e9f6c"
            },
            "downloads": -1,
            "filename": "gocept.pseudonymize-3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e7d561669133060f335eab19a227f962",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 12591,
            "upload_time": "2023-07-18T05:44:02",
            "upload_time_iso_8601": "2023-07-18T05:44:02.990592Z",
            "url": "https://files.pythonhosted.org/packages/e7/8f/76e11f19854b85972ea5952b569ee1fffba60f3f67d7b494f823b3fb6854/gocept.pseudonymize-3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-18 05:44:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gocept",
    "github_project": "gocept.pseudonymize",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "gocept.pseudonymize"
}
        
Elapsed time: 0.09354s