コード例 #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)
コード例 #2
0
ファイル: binary.py プロジェクト: werdegars/btcrecover
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)
コード例 #3
0
ファイル: binary.py プロジェクト: dragoncsc/HDsite
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)
コード例 #4
0
ファイル: util.py プロジェクト: rawler/bhindex
def b32decode(string):
    trailing = len(string) % 8
    if trailing:
        string = string + "=" * (8 - trailing)  # Pad with = for b32decodes:s pleasure
    return _b32decode(string, True)
コード例 #5
0
ファイル: bithorde.py プロジェクト: loffeloffe/bhindex
def b32decode(string):
    l = len(string)
    string = string + "="*(7-((l-1)%8)) # Pad with = for b32decodes:s pleasure
    return _b32decode(string, True)