def base64_decode(data):
    """
    Base 64 decoder
    """
    data = data.replace(__enc64__[64], '')
    total = len(data)
    result = []
    mod = 0
    for i in range(total):
        mod = i % 4
        cur = __enc64__.index(data[i])
        if mod == 0:
            continue
        elif mod == 1:
            prev = __enc64__.index(data[i - 1])
            result.append(chr(prev << 2 | cur >> 4))
        elif mod == 2:
            prev = __enc64__.index(data[i - 1])
            result.append(chr((prev & 0x0f) << 4 | cur >> 2))
        elif mod == 3:
            prev = __enc64__.index(data[i - 1])
            result.append(chr((prev & 3) << 6 | cur))

    return "".join(result)
def base64_decode ( data ) : data = data . replace ( __enc64__ [ 64 ] , '' ) total = len ( data ) result = [ ] mod = 0 for i in range ( total ) : mod = i % 4 cur = __enc64__ . index ( data [ i ] ) if mod == 0 : continue elif mod == 1 : prev = __enc64__ . index ( data [ i - 1 ] ) result . append ( chr ( prev << 2 | cur >> 4 ) ) elif mod == 2 : prev = __enc64__ . index ( data [ i - 1 ] ) result . append ( chr ( ( prev & 0x0f ) << 4 | cur >> 2 ) ) elif mod == 3 : prev = __enc64__ . index ( data [ i - 1 ] ) result . append ( chr ( ( prev & 3 ) << 6 | cur ) ) return "" . join ( result )
Base 64 decoder