Signing utilities for Django, to try out an API which is being proposed for inclusion in Django core.
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1 commit behind WiserTogether:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This project demonstrates a proposed signing API for Django. You can run the 
test suite like so:

    cd examples
    ./ test

The API is under heavy development. It is described in more detail here:

The mailing list discussion is here:


 - Add support for expiring signatures
 - Try using a class instead of functions, as suggested by Johannes Dollinger
 - Cookie signing functions
 - Middleware that illustrates the proposed request cookie signing API
 - Support key migration from an OLD_SECRET_KEY to the current one

Part of this module is, which I hope to contribute to 
django.utils. baseconv allows you to convert between integers and various 
different string representations of those numbers. For example:

>>> import baseconv
>>> i = 102971
>>> baseconv.base2.from_int(i)
>>> baseconv.base16.from_int(i)
>>> baseconv.base36.from_int(i)
>>> baseconv.base62.from_int(i)

You can convert back again using the to_int(string) method:

>>> baseconv.base2.to_int('11001001000111011')
>>> baseconv.base16.to_int('1923B')
>>> baseconv.base36.to_int('27gb')
>>> baseconv.base62.to_int('Qmp')

This is principally useful as a compression scheme for transmitting numbers as 
ascii text - in particular for URLs (URL shortening services such as 
use this technique). The signed cookie implementation uses this to represent 
a unix timestamp in as few characters as possible, to keep cookie lengths 

If you wish to use your own shortening scheme you can use the BaseConvertor 
class. For example, you might want to just use characters that aren't easily confused with each other - the alphabet omitting i, l and o:

>>> convertor = baseconv.BaseConverter('abcdefghjkmnpqrstuvwxyz')
>>> convertor.from_int(102971)
>>> convertor.to_int('jmsa')