def fingerprint_from_file(filename):
    """Extract a fingerprint from a GPG public key file"""
    cmd = flatten([gnupg_bin(), gnupg_home(), filename])
    outp = stderr_output(cmd).split('\n')
    if not outp[0].startswith('pub'):
        raise CryptoritoError('probably an invalid gpg key')

    return outp[1].strip()
Extract a fingerprint from a GPG public key file