Skip to content

Instantly share code, notes, and snippets.

@simonw
Created January 26, 2010 22:22
Show Gist options
  • Select an option

  • Save simonw/287310 to your computer and use it in GitHub Desktop.

Select an option

Save simonw/287310 to your computer and use it in GitHub Desktop.
# 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