[#EVP_PKEY_encrypt]
= EVP&lowbar;PKEY&lowbar;encrypt
:mrdocs:

Encrypt data with a public key using a context from EVP&lowbar;PKEY&lowbar;encrypt&lowbar;init()&period;

== Synopsis

Declared in `&lt;openssl&sol;evp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
EVP&lowbar;PKEY&lowbar;encrypt(
    xref:EVP_PKEY_CTX.adoc[EVP&lowbar;PKEY&lowbar;CTX]* ctx,
    unsigned char* out,
    size&lowbar;t* outlen,
    unsigned char const* in,
    size&lowbar;t inlen);
----

== Return Value

1 on success, or a non&hyphen;positive value on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ctx*
| Encryption context holding the public key&period;
| *out*
| Output buffer for ciphertext, or NULL to query the required size via `outlen&period;`
| *outlen*
| On entry, capacity of `out` when non&hyphen;NULL&semi; on return, bytes written or required&period;
| *in*
| Plaintext bytes to encrypt&period;
| *inlen*
| Length of `in` in bytes&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
