def _buildFromFingerprint(self, fingerprint): """Build key information from a fingerprint.""" context = gpgme.Context() # retrive additional key information try: key = context.get_key(fingerprint, False) except gpgme.GpgmeError: key = None if key and valid_fingerprint(key.subkeys[0].fpr): self._buildFromGpgmeKey(key)
def sanitizeFingerprint(self, fingerprint): """See IGPGHandler.""" # remove whitespaces, truncate to max of 40 (as per v4 keys) and # convert to upper case fingerprint = fingerprint.replace(' ', '') fingerprint = fingerprint[:40].upper() if not valid_fingerprint(fingerprint): return None return fingerprint
def sanitize_fingerprint(fingerprint): """Sanitize a GPG fingerprint. This is the ultimate implementation of IGPGHandler.sanitizeFingerprint. """ # remove whitespaces, truncate to max of 40 (as per v4 keys) and # convert to upper case fingerprint = fingerprint.replace(' ', '') fingerprint = fingerprint[:40].upper() if not valid_fingerprint(fingerprint): return None return fingerprint