Created
January 26, 2010 22:22
-
-
Save simonw/287310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://github.com/simonw/django-signed/raw/master/django_signed/baseconv.py | |
| from baseconv import BaseConverter | |
| class Base32Converter(BaseConverter): | |
| # Human-friendly, see http://www.crockford.com/wrmg/base32.html | |
| replacements = { | |
| 'o': '0', | |
| 'O': '0', | |
| 'I': '1', | |
| 'i': '1', | |
| 'L': '1', | |
| 'l': '1', | |
| } | |
| def __init__(self): | |
| super(Base32Converter, self).__init__( | |
| '0123456789abcdefghjkmnpqrstvwxyz' | |
| ) | |
| def to_int(self, s): | |
| for key, value in self.replacements.items(): | |
| s = s.replace(key, value) | |
| return super(Base32Converter, self).to_int(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment