{ "info": { "author": "Attila Ol\u00e1h", "author_email": "attilaolah@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: Public Domain", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "Integer Permutation |License|\n=============================\n\n.. image:: https://d2weczhvl823v0.cloudfront.net/attilaolah/intperm.py/trend.png\n :target: https://bitdeli.com/free\n :alt: Bitdeli\n.. image:: https://travis-ci.org/attilaolah/intperm.py.png?branch=master\n :target: https://travis-ci.org/attilaolah/intperm.py\n :alt: Build Status\n.. image:: https://coveralls.io/repos/attilaolah/intperm.py/badge.png?branch=master\n :target: https://coveralls.io/r/attilaolah/intperm.py\n :alt: Coverage Status\n.. image:: https://pypip.in/v/intperm/badge.png\n :target: https://pypi.python.org/pypi/intperm/\n :alt: Version\n.. image:: https://pypip.in/d/intperm/badge.png?period=month\n :target: https://pypi.python.org/pypi/intperm/\n :alt: Downloads\n\nThis package implements a simple, configurable permutation on the set of 64-bit\nintegers.\n\nThe permutation is based on a bitmask that maps each bit of the input to a bit\nof the output. The bitmask is expanded from a random seed using a PRNG_, as\ndescribed by *George Marsaglia* in his paper called `Xorshift RNGs`_. The\npermutations are thus believed to be unpredictable, provided provided that the\nseed is kept secret.\n\n.. _PRNG: https://en.wikipedia.org/wiki/Pseudorandom_number_generator\n.. _Xorshift RNGs: http://www.jstatsoft.org/v08/i14/paper\n\nUsage\n-----\n\nCreate a new ``Permutation`` instance by passing in an optional seed.\n\n.. code:: python\n\n >>> fromo intperm import Permutation\n >>> perm = Permutation(42)\n >>> perm.map_to(37)\n 13750393542137160527L\n >>> perm.map_from(13750393542137160527)\n 37\n\nNot providing a seed will create a random permutation:\n\n.. code:: python\n\n >>> perm = Permutation()\n >>> perm.map_from(perm.map_to(37)) == 37\n True\n\nUse cases\n---------\n\nUse cases may vary, but an example that I find useful is generating\nhard_-to-guess, random-looking tokens based on IDs stored in a database.\nThe IDs can be used together with the seed to decode the original ID, but their\ncardinality_ is the same as that of the IDs themselves. When used smartly,\nthis can save you from having to index those tokens in the database.\n\nAnother good example is randomising IDs of private objects that are available\nvia some sort of an API. Let's say the user accounts on your website are\naccessible via the path ``/user/:id``, where ``:id`` is the user's ID. Someone\ncould track the growth of your user base just by enumerating the URLs and\nkeeping track of the status codes (e.g. 403 vs. 404).\n\nUsing this simple permutation, user IDs can be kept unpredictable, rendering\nthese kinds of attacks practically useless.\n\n.. _hard: https://en.wikipedia.org/wiki/NP-hard\n.. _cardinality: https://en.wikipedia.org/wiki/Cardinality\n\nSee also\n--------\n\nThis library is also implemented in Ruby_ and Go_.\n\n.. _Ruby: https://github.com/attilaolah/intperm.rb\n.. _Go: https://github.com/attilaolah/intperm.go\n\n.. |License| image:: https://pypip.in/license/intperm/badge.png", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/attilaolah/intperm.py", "keywords": null, "license": "Public Domain", "maintainer": null, "maintainer_email": null, "name": "intperm", "package_url": "https://pypi.org/project/intperm/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/intperm/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/attilaolah/intperm.py" }, "release_url": "https://pypi.org/project/intperm/1.1.1/", "requires_dist": null, "requires_python": null, "summary": "A simple permutation for arbitrary size integers.", "version": "1.1.1" }, "last_serial": 993679, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "a34d9942485b00786d4e71c59c80a64d", "sha256": "953814346e11d05ffed654d5b1ff0d5e61e3d40af988b0fe6ad9b0ddeaf826fc" }, "downloads": -1, "filename": "intperm-1.1.0.tar.gz", "has_sig": false, "md5_digest": "a34d9942485b00786d4e71c59c80a64d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4849, "upload_time": "2014-02-07T04:37:08", "url": "https://files.pythonhosted.org/packages/80/05/41858ac8a3970ca8c69edb2bd08fe5dc8e4831afe7f88ba3c31b5932eaa5/intperm-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "1271c7aaba133dd2c8a4541fa31eb06b", "sha256": "8b83697faea4c329ca7c49220f62ce0dd0630b33b510bb4fc9eb66dda54f128e" }, "downloads": -1, "filename": "intperm-1.1.1.tar.gz", "has_sig": false, "md5_digest": "1271c7aaba133dd2c8a4541fa31eb06b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4742, "upload_time": "2014-02-07T16:09:08", "url": "https://files.pythonhosted.org/packages/c6/26/5253912adf5aa8bad2a0a23f4552231a19d19ac98b8ad99c88184917ebe6/intperm-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1271c7aaba133dd2c8a4541fa31eb06b", "sha256": "8b83697faea4c329ca7c49220f62ce0dd0630b33b510bb4fc9eb66dda54f128e" }, "downloads": -1, "filename": "intperm-1.1.1.tar.gz", "has_sig": false, "md5_digest": "1271c7aaba133dd2c8a4541fa31eb06b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4742, "upload_time": "2014-02-07T16:09:08", "url": "https://files.pythonhosted.org/packages/c6/26/5253912adf5aa8bad2a0a23f4552231a19d19ac98b8ad99c88184917ebe6/intperm-1.1.1.tar.gz" } ] }