Example #1
0
def b32decode(source):
    if isinstance(source, unicode):
        source = source.encode('ascii')
    source = source.translate(_b32_translate)
    remainder = len(source) & 7
    if remainder:
        source += _b32_decode_pad[:-remainder]
    return _b32decode(source, True)
Example #2
0
def b32decode(source):
    """
    wrapper around :func:`base64.b32decode`
    which handles common mistyped chars.
    padding optional, ignored if present.
    """
    # encode & correct for typos
    if isinstance(source, unicode):
        source = source.encode("ascii")
    source = source.translate(_b32_translate)

    # pad things so final string is multiple of 8
    remainder = len(source) & 0x7
    if remainder:
        source += _b32_decode_pad[:-remainder]

    # XXX: py27 stdlib's version of this has some inefficiencies,
    #      could look into using optimized version.
    return _b32decode(source, True)
Example #3
0
def b32decode(source):
    """
    wrapper around :func:`base64.b32decode`
    which handles common mistyped chars.
    padding optional, ignored if present.
    """
    # encode & correct for typos
    if isinstance(source, unicode):
        source = source.encode("ascii")
    source = source.translate(_b32_translate)

    # pad things so final string is multiple of 8
    remainder = len(source) & 0x7
    if remainder:
        source += _b32_decode_pad[:-remainder]

    # XXX: py27 stdlib's version of this has some inefficiencies,
    #      could look into using optimized version.
    return _b32decode(source, True)
Example #4
0
def b32decode(string):
    trailing = len(string) % 8
    if trailing:
        string = string + "=" * (8 - trailing)  # Pad with = for b32decodes:s pleasure
    return _b32decode(string, True)
Example #5
0
def b32decode(string):
    l = len(string)
    string = string + "="*(7-((l-1)%8)) # Pad with = for b32decodes:s pleasure
    return _b32decode(string, True)