encrypt¶
-
KeyManager.
encrypt
(message: Union[str, bytes], pad=None, hashing: cryptography.hazmat.primitives.hashes.HashAlgorithm = <cryptography.hazmat.primitives.hashes.SHA256 object>) → bytes[source]¶ Encrypt a message using the loaded
public_key
- returns the ciphertext as base64 encoded bytes.NOTE: Only works for RSA public keys
- Parameters
message (str|bytes) – The message to encrypt, e.g.
hello world
pad – (RSA only) An instance of a cryptography padding class, e.g.
padding.PSS
hashing (HashAlgorithm) – (ECDSA/RSA) Use this hashing method for padding/signatures
- Return bytes ciphertext
The encrypted version of
message
- encoded with Base64 for easy storage/transport