This example Django app demonstrates two approaches to pseudonymizing personal data with masking functions.
- Example 1 employs getter and setter methods to interface with the pseudonymized model fields.
- Example 2 creates a custom Field class to handle value masking/unmasking automatically.
...
For a more detailed explanation, check out the blog post on Cuttlesoft.com.
git clone https://github.com/cuttlesoft/django-pseudonymization-example.git
cd django-pseudonymization-example
Example 1, branch: properties
git checkout properties
Example 2, branch: fields
git checkout fields
This example uses Django 2.0, which supports Python 3.4, 3.5, and 3.6. To properly run this example you'll need:
- Python 3.4 or greater
- PostgreSQL
- pipenv
Install dependencies with pipenv
$ pipenv install
Creating a virtualenv for this project…
...
Virtualenv location: /Users/user/.venvs/django-pseudonymization-example-ztyUS4al
Installing dependencies from Pipfile.lock (5d8b51)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 3/3 — 00:00:09
To activate this project's virtualenv, run the following:
$ pipenv shell
Activate virtual environment with pipenv
$ pipenv shell
Spawning environment shell (/bin/zsh). Use 'exit' to leave.
(django-pseudonymization-example-ztyUS4al) $
createdb django_pseudonymization_example
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
June 25, 2018 - 21:16:11
Django version 2.0.6, using settings 'app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Our mask
/unmask
functions are intended for this example only, to enable demonstration of the application's handling of masking and unmasking. They do not sufficiently protect the data, as it is reasonably likely that someone accessing the data would be able to simply reverse the shifted characters, re-identifying users without any additional information present.
Please read CONTRIBUTING.md for details on our code of conduct.
This project is licensed under the MIT License - see the LICENSE file for details
- 🐙 Cuttlesoft.com
- 🐦 @cuttlesoft
- 📩 hello [at] cuttlesoft [dot] com