PublicKey

PublicKey contains the RSA public key from a private/public keypair.

It also allows extraction of the public key from a keypair.

This is useful for encryption, you can encrypt data with someone's public key and they can decrypt it with their private key.

Example

auto public = new PublicKey(cast(char[])File.get("public.pem"));
auto encrypted = public.encrypt(cast(ubyte[])"Hello, how are you today?");
auto pemData = public.pemFormat;

Constructors

this
this(const(char)[] publicPemData)

Generate a PublicKey object from the passed PEM formatted data

this
this(PrivateKey key)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

decrypt
ubyte[] decrypt(const(ubyte)[] data)

Decrypts data previously encrypted with the matching PrivateKey

encrypt
ubyte[] encrypt(const(ubyte)[] data)

Encrypt the passed data using the PublicKey

pemFormat
string pemFormat()

Return a PublicKey in the PEM format.

verify
bool verify(const(ubyte)[] data, const(ubyte)[] signature)

Verify the data passed was signed with the public key.

Variables

_evpKey
EVP_PKEY* _evpKey;
Undocumented in source.

Meta