def validate(self, value): super(KeyField, self).validate(value) # try to import it as an RSA key try: crypto.get_key(value) except EncryptionImportKeyException as e: raise forms.ValidationError("Failed to import key: %s" % (e.message)) return value
def get_public_key(self): """ return public key cipher object based on self.text """ return crypto.get_key(self.text)