import base64
import hashlib


def fingerprint(key):
    """Convert an SSH RSA/DSA public key to a fingerprint string"""
    key = base64.b64decode(key.encode('ascii'))
    fp_plain = hashlib.md5(key).hexdigest()
    return ':'.join(a+b for a,b in zip(fp_plain[::2], fp_plain[1::2]))