Binary exponentation with modulo I have implemented binary exponentiation. Is this good?

def quad_pow(base, exponent, modul): 
    alpha = (bin(exponent).replace('0b', ''))[::-1]
    a = 1
    b = base

    for i in range(0, len(alpha)):
        if int(alpha[i]) == 1:
            a = (a * b) % modul
        b = (b*b) % modul
    return a
The string manipulation is avoidable, by working with bits of the exponent directly:

def quad_pow(base, exponent, modul): 
    a = 1
    b = base

    while exponent:
        if exponent &amp; 1:
            a = (a * b) % modul
        b = (b * b) % modul
        exponent &gt;&gt;= 1
    return a