{ "info": { "author": "Sean Meyer", "author_email": "slinkymabyday@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Information Technology", "Intended Audience :: Other Audience", "Intended Audience :: System Administrators", "Natural Language :: English", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: OS Independent", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development" ], "description": "======================\nDjango Encrypted Id (cryptography)\n======================\n\n.. image:: https://badge.fury.io/py/django-encrypted-id-cryptography.svg\n :target: https://badge.fury.io/py/django-encrypted-id-cryptography\n\n.. image:: https://travis-ci.org/slinkymanbyday/django-encrypted-id-cryptography.svg?branch=master\n :target: https://travis-ci.org/slinkymanbyday/django-encrypted-id-cryptography\n\n\ndjango-encrypted-id-cryptography is a Django model which allows the use of encrypted ids for when you don't want to expose the regular pk.\n\n**Note: This is a fork from django-encrypted-id and acts *mostly* a drop in replacement, it requires an additional settings and the encrypted ids are not compaitable. It also uses a different crypto library**\n\n\nRequirements\n------------\nThe following have been tested, however it should work with more.\n\n* Django [1.11, 2.0, 2.2]\n* Python [2.7, 3.5]\n* Cryptography\n\nQuickstart\n----------\n\nInstall django-encrypted-id-cryptography::\n\n pip install django-encrypted-id-cryptography\n\n\nCreate an encryption key:\n\n.. code-block:: python\n\n > from cryptography.fernet import Fernet\n > Fernet.generate_key()\n\n '3CNek72sQ3syTXX6h-Z1t3OLKKY1lfAgnTW_THUz37M='\n\n\n.. code-block:: python\n\n ID_ENCRYPT_KEY = ['3CNek72sQ3syTXX6h-Z1t3OLKKY1lfAgnTW_THUz37M=']\n\nFeatures\n--------\n\nThis password validator returns a ValidationError if the PWNED Passwords API\ndetects the password in its data set. Note that the API is heavily rate-limited,\nso there is a timeout (:code:`PWNED_VALIDATOR_TIMEOUT`).\n\nIf :code:`PWNED_VALIDATOR_FAIL_SAFE` is True, anything besides an API-identified bad password\nwill pass, including a timeout. If :code:`PWNED_VALIDATOR_FAIL_SAFE` is False, anything\nbesides a good password will fail and raise a ValidationError.\n\n\nUse\n--------\n\nConsider this example model:\n\n.. code-block:: python\n\n from django.db import models\n\n from encrypted_id.models import EncryptedIDModel\n\n\n class Foo(EncryptedIDModel):\n text = models.TextField()\n\n\nBy inheriting from ``EncryptedIDModel``, you get .ekey as a property on your\nmodel instances. This is how they will look like:\n\n.. code-block:: python\n\n In [1]: from tapp.models import Foo\n\n In [2]: f = Foo.objects.create(text=\"asd\")\n\n In [3]: f.id\n Out[3]: 1\n\n In [4]: f.ekey\n Out[4]: 'gAAAAABcyQ2WlhRT6zec6WCRMJ3mDkZL9SCy98JeMvrERki6DJgc3WeIRMbAMm86_zmV0sP3_iPvbAHGgb7RfEGrnIIYdggaig=='\n You can do reverse lookup:\n\n In [5]: from encrypted_id import decode\n\n In [6]: decode(f.ekey)\n Out[6]: 1\n\nIf you can not inherit from the helper base class, no problem, you can just use\nthe ``ekey()`` function from ``encrypted_id`` package:\n\n.. code-block:: python\n\n In [7]: from encrypted_id import ekey\n\n In [8]: from django.contrib.auth.models import User\n\n In [9]: ekey(User.objects.get(pk=1))\n Out[9]: 'gAAAAABcyQ2WlhRT6zec6WCRMJ3mDkZL9SCy98JeMvrERki6DJgc3WeIRMbAMm86_zmV0sP3_iPvbAHGgb7RfEGrnIIYdggaig=='\n\n\nTo do the reverse lookup, you have two helpers available. First is provided by\n``EncryptedIDManager``, which is used by default if you inherit from\n``EncryptedIDModel``, and have not overwritten the ``.objects``:\n\n.. code-block:: python\n\n In [10]: Foo.objects.get_by_ekey(f.ekey)\n Out[10]: \n\n\nBut sometimes you will prefer the form:\n\n.. code-block:: python\n\n In [11]: Foo.objects.get_by_ekey_or_404(f.ekey)\n Out[11]: \n\n\nWhich works the same, but instead of raising ``DoesNotExist``, it raises\n``Http404``, so it can be used in views.\n\nYou your manager is not inheriting from ``EncryptedIDManager``, you can use:\n\n.. code-block:: python\n\n In [12]: e = ekey(User.objects.first())\n\n In [13]: e\n Out[13]: 'gAAAAABcyQ2WlhRT6zec6WCRMJ3mDkZL9SCy98JeMvrERki6DJgc3WeIRMbAMm86_zmV0sP3_iPvbAHGgb7RfEGrnIIYdggaig=='\n\n In [14]: get_object_or_404(User, e)\n Out[14]: \n\n\n``encrypted_id.get_object_or_404``, as well as\n``EncryptedIDManager.get_by_ekey`` and\n``EncryptedIDManager.get_by_ekey_or_404`` take extra keyword argument, that can\nbe used to filter if you want.\n\nIf you are curious, the regex used to match the generated ids is:\n\n.. code-block:: python\n\n \"[0-9a-zA-Z-_=]+\"\n\n\nRunning Tests\n-------------\n\n::\n\n source /bin/activate\n (myenv) $ pip install tox\n (myenv) $ tox\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/slinkymanbyday/django-encrypted-id-cryptography", "keywords": "Django,Web", "license": "BSD", "maintainer": "Sean Meyer", "maintainer_email": "slinkymabyday@gmail.com", "name": "django-encrypted-id-cryptography", "package_url": "https://pypi.org/project/django-encrypted-id-cryptography/", "platform": "", "project_url": "https://pypi.org/project/django-encrypted-id-cryptography/", "project_urls": { "Homepage": "https://github.com/slinkymanbyday/django-encrypted-id-cryptography" }, "release_url": "https://pypi.org/project/django-encrypted-id-cryptography/1.1.0/", "requires_dist": [ "Django (>=1.11)", "cryptography" ], "requires_python": "", "summary": "Encrypted IDs for Django Models", "version": "1.1.0" }, "last_serial": 5250877, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "b99b60f2bc8b5b88030f7256ac8e1e57", "sha256": "c8b6102496b7db3ce88f2d6d23b7907a473bd983febb1e43f240e05b308b88ca" }, "downloads": -1, "filename": "django_encrypted_id_cryptography-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b99b60f2bc8b5b88030f7256ac8e1e57", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6578, "upload_time": "2019-05-10T03:46:53", "url": "https://files.pythonhosted.org/packages/8f/be/51d93abd9f22ce550659fef0a63049a2b4d09bec467897e2f4a8a878c46b/django_encrypted_id_cryptography-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f02e8ed7d93beeddc9b040f04f3c7f9e", "sha256": "205bd30cc52e078989d99551c5445b36806a92d438e7fb3585c73e70b314d46b" }, "downloads": -1, "filename": "django-encrypted-id-cryptography-1.1.0.tar.gz", "has_sig": false, "md5_digest": "f02e8ed7d93beeddc9b040f04f3c7f9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5128, "upload_time": "2019-05-10T03:46:55", "url": "https://files.pythonhosted.org/packages/8b/34/55385cacf4680e0723964765febda4f4c3298a786a1f71c643cfd1e5688b/django-encrypted-id-cryptography-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b99b60f2bc8b5b88030f7256ac8e1e57", "sha256": "c8b6102496b7db3ce88f2d6d23b7907a473bd983febb1e43f240e05b308b88ca" }, "downloads": -1, "filename": "django_encrypted_id_cryptography-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b99b60f2bc8b5b88030f7256ac8e1e57", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6578, "upload_time": "2019-05-10T03:46:53", "url": "https://files.pythonhosted.org/packages/8f/be/51d93abd9f22ce550659fef0a63049a2b4d09bec467897e2f4a8a878c46b/django_encrypted_id_cryptography-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f02e8ed7d93beeddc9b040f04f3c7f9e", "sha256": "205bd30cc52e078989d99551c5445b36806a92d438e7fb3585c73e70b314d46b" }, "downloads": -1, "filename": "django-encrypted-id-cryptography-1.1.0.tar.gz", "has_sig": false, "md5_digest": "f02e8ed7d93beeddc9b040f04f3c7f9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5128, "upload_time": "2019-05-10T03:46:55", "url": "https://files.pythonhosted.org/packages/8b/34/55385cacf4680e0723964765febda4f4c3298a786a1f71c643cfd1e5688b/django-encrypted-id-cryptography-1.1.0.tar.gz" } ] }