{ "info": { "author": "Constantin Roganov", "author_email": "rccbox@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Database", "Topic :: Security", "Topic :: Security :: Cryptography" ], "description": "######################\npeewee_encrypted_field\n######################\n\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat \n :target: https://opensource.org/licenses/MIT \n \n.. image:: https://badge.fury.io/gh/brake%2Fpeewee_encrypted_field.svg\n :target: https://badge.fury.io/gh/brake%2Fpeewee_encrypted_field\n \n.. image:: https://img.shields.io/badge/Python-2.7-red.svg\n\n.. _fernet-py: https://github.com/heroku/fernet-py\n.. _Fernet tokens:\n.. _fernet spec: https://github.com/fernet/spec\n.. _Pycrypto: https://pypi.python.org/pypi/pycrypto\n\nEncrypted field for `Peewee ORM `_ models to save data in DB in encrypted form.\n\nData stored in DataBase as `Fernet tokens`_. After you define an encryption key all cryptography will be performed transparently for your application.\n\nUses simple fernet implementation https://github.com/heroku/fernet-py\n\nIdea caught from SQLAlchemy's `EncryptedType `_.\n\nContents\n********\n\n* `Implementation Details`_ \n* `Features`_\n* `Installation`_\n* `Usage`_\n* `Key Derivation Example`_\n\n.. _Implementation Details:\n\nImplementation Details\n----------------------\n\nA fernet-py_ package can use Pycrypto_ or `M2Crypto `_ as backend (`details `_). Same belongs to this module due to its dependency from fernet-py_. Note that ``pip`` uses Pycrypto_ as a default dependency when install fernet-py_. \n**Length of entire key is 32 bytes**, 16 bytes per both signing and encryption keys, as stated in `specification `_.\n\n.. _Features:\n\nFeatures\n--------\n\nYou have to set ``key`` as a property of appropriate ``EncryptedField``. **You need to set this property once per** ``Model`` **per** ``Model`` **'s** ``Field``.\nIf you attempt to set ``key`` property for a ``Field`` whose ``key`` already has been set, exception ``EncryptedField.KeyAlreadyExists`` will be raised. To change the ``key`` on the fly you have to explictly perform ``del SomeEncryptedField.key`` and then set this property to desired value again.\n\n.. _Installation:\n\nInstallation\n------------\n\n``pip install peewee_encrypted_field``\n\nor, if you downloaded source, \n\n``python setup.py install``\n\n.. _Usage:\n\nUsage\n-----\n\nAt first, import module\n\n.. code-block:: python\n\n from peewee import *\n from peewee_encrypted_field import EncryptedField\n\nThen, define the model with :code:`EncryptedField`\n\n.. code-block:: python\n \n class SecureTable(BaseModel):\n sensitive_data = EncryptedField()\n\n class Meta:\n db_table = 'SecureTable'\n\nAfter, configure field's encryption key\n\n.. code-block:: python\n \n SecureTable.sensitive_data.key = key_derivation_fn() # a hypotetical key derivation \n # function returning 32 byte key\n\nFinally, save and retrieve data in a Peewee's usual manner\n\n.. code-block:: python\n\n new_secret = SecureTable(sensitive_data='My New BIG Secret')\n new_secret.save()\n\n.. _Key Derivation Example:\n\nKey Derivation Example\n----------------------\n\nExample Key Derivation Function baded on Pycrypto_ module.\n\n`Please take look at this Gist `_ - it can contain more actual version of code below.\n\n.. code-block:: python\n\n from binascii import unhexlify\n from functools import partial\n from Crypto.Protocol import KDF\n from Crypto.Hash import SHA512, HMAC\n \n _SALT = unhexlify('48B755AB80CD1C3DA61182D3DCD2E3A2CA869B783618FF6551FB4B0CDC3B8066') # some salt\n _KEY_LENGTH = 32\n \n key_derivation_fn = partial( \n KDF.PBKDF2,\n salt=_SALT,\n dkLen=_KEY_LENGTH,\n count=5000,\n prf=lambda p,s: HMAC.new(p,s,SHA512).digest()\n )\n\n # KDF usage\n SecureTable.sensitive_data.key = key_derivation_fn(text_password)", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/brake/peewee_mssql/archive/0.0.2.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brake/peewee_encrypted_field", "keywords": "database,ORM,peewee,encryption,fernet,ciphering", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "peewee_encrypted_field", "package_url": "https://pypi.org/project/peewee_encrypted_field/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/peewee_encrypted_field/", "project_urls": { "Download": "https://github.com/brake/peewee_mssql/archive/0.0.2.zip", "Homepage": "https://github.com/brake/peewee_encrypted_field" }, "release_url": "https://pypi.org/project/peewee_encrypted_field/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Field with encryption/decryption on save/read for use in Peewee ORM models", "version": "0.0.2" }, "last_serial": 2395597, "releases": { "0.0.1": [], "0.0.2": [ { "comment_text": "", "digests": { "md5": "153acada7388f7f70a04531877f8ba6b", "sha256": "a18ae1e2d87cf05b4c781210dbd4e56dec1b090d8f54547dbcf0fe3cfa799435" }, "downloads": -1, "filename": "peewee_encrypted_field-0.0.2.tar.gz", "has_sig": false, "md5_digest": "153acada7388f7f70a04531877f8ba6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4801, "upload_time": "2016-10-12T16:50:17", "url": "https://files.pythonhosted.org/packages/dc/08/0a8b530efff8c424baa81e18be116b4fd6419c6387298042b3b0cd86b320/peewee_encrypted_field-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "153acada7388f7f70a04531877f8ba6b", "sha256": "a18ae1e2d87cf05b4c781210dbd4e56dec1b090d8f54547dbcf0fe3cfa799435" }, "downloads": -1, "filename": "peewee_encrypted_field-0.0.2.tar.gz", "has_sig": false, "md5_digest": "153acada7388f7f70a04531877f8ba6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4801, "upload_time": "2016-10-12T16:50:17", "url": "https://files.pythonhosted.org/packages/dc/08/0a8b530efff8c424baa81e18be116b4fd6419c6387298042b3b0cd86b320/peewee_encrypted_field-0.0.2.tar.gz" } ] }