Metadata-Version: 1.1
Name: intperm
Version: 1.1.0
Summary: A simple permutation for arbitrary size integers.
Home-page: https://github.com/attilaolah/intperm.py
Author: Attila Oláh
Author-email: attilaolah@gmail.com
License: Public Domain
Description: Permutation
        ===========
        
        .. role:: python(code)
           :language: pythonh
        
        .. image:: https://d2weczhvl823v0.cloudfront.net/attilaolah/intperm.py/trend.png
           :target: https://bitdeli.com/free
           :alt: Bitdeli
        .. image:: https://travis-ci.org/attilaolah/intperm.py.png?branch=master
           :target: https://travis-ci.org/attilaolah/intperm.py
           :alt: Build Status
        .. image:: https://coveralls.io/repos/attilaolah/intperm.py/badge.png?branch=master
           :target: https://coveralls.io/r/attilaolah/intperm.py
           :alt: Coverage Status
        .. image:: https://badge.fury.io/py/intperm.png
           :target: http://badge.fury.io/py/intperm
           :alt: PyPI version
        
        This package implements a simple, configurable permutation on the set of 64-bit
        integers.
        
        The permutation is based on a bitmask that maps each bit of the input to a bit
        of the output. The bitmask is expanded from a random seed using a PRNG_, as
        described by *George Marsaglia* in his paper called `Xorshift RNGs`_. The
        permutations are thus believed to be unpredictable, provided provided that the
        seed is kept secret.
        
        .. _PRNG: //en.wikipedia.org/wiki/Pseudorandom_number_generator
        .. _Xorshift RNGs: http://www.jstatsoft.org/v08/i14/paper
        
        Usage
        -----
        
        Create a new :python:`Permutation` instance by passing in an optional seed.
        
        .. code:: python
        
            >>> fromo intperm import Permutation
            >>> perm = Permutation(42)
            >>> perm.map_to(37)
            13750393542137160527L
            >>> perm.map_from(13750393542137160527)
            37
        
        Not providing a seed will create a random permutation:
        
        .. code:: python
        
            >>> perm = Permutation()
            >>> perm.map_from(perm.map_to(37)) == 37
            True
        
        Use cases
        ---------
        
        Use cases may vary, but an example that I find useful is generating
        hard_-to-guess, random-looking tokens based on IDs stored in a database.
        The IDs can be used together with the seed to decode the original ID, but their
        cardinality_ is the same as that of the IDs themselves. When used smartly,
        this can save you from having to index those tokens in the database.
        
        Another good example is randomising IDs of private objects that are available
        via some sort of an API. Let's say the user accounts on your website are
        accessible via the path ``/user/:id``, where ``:id`` is the user's ID. Someone
        could track the growth of your user base just by enumerating the URLs and
        keeping track of the status codes (e.g. 403 vs. 404).
        
        Using this simple permutation, user IDs can be kept unpredictable, rendering
        these kinds of attacks practically useless.
        
        .. _hard: //en.wikipedia.org/wiki/NP-hard
        .. _cardinality: //en.wikipedia.org/wiki/Cardinality
        
        See also
        --------
        
        This library is also implemented in Ruby_ and Go_.
        
        .. _Ruby: //github.com/attilaolah/intperm.rb
        .. _Go: //github.com/attilaolah/intperm.go
        
        License
        -------
        
        `Public domain`_.
        
        .. _Public domain: //github.com/attilaolah/intperm.py/blob/master/LICENSE
        
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Public Domain
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
