def ssh_encrypt_text(ssh_public_key, text):
 if isinstance(text, six.text_type):
  text = text.encode('utf-8')
 try:
  pub_bytes = ssh_public_key.encode('utf-8')
  pub_key = serialization.load_ssh_public_key(pub_bytes, backends.default_backend())
  return pub_key.encrypt(text, padding.PKCS1v15())
 except Exception as exc:
  raise exception.EncryptionFailure(reason=six.text_type(exc))

def ssh_encrypt_text ( ssh_public_key , text ) : if isinstance ( text , six . text_type ) : text = text . encode ( 'utf-8' ) try : pub_bytes = ssh_public_key . encode ( 'utf-8' ) pub_key = serialization . load_ssh_public_key ( pub_bytes , backends . default_backend ( ) ) return pub_key . encrypt ( text , padding . PKCS1v15 ( ) ) except Exception as exc : raise exception . EncryptionFailure ( reason = six . text_type ( exc ) )
encrypt text with an ssh public key .