decrypt()
The decrypt
function decrypts the given Base64-encoded ciphertext
using the given private_key
(see below). It uses the RSAES-OAEP padding scheme. The optional parameter passphrase
is the passphrase for decrypting an encrypted private key (default ""
). For an unencrypted private key the passphrase
should be omitted or ""
.
The function returns the decrypted data as a string.
Example
Private Key Format
Private keys should be supplied in PKCS #8 syntax using PEM encoding:
for an unencrypted key – or for an encrypted (i.e. passphrase-secured) key:
For such PKCS #8 keys the -----BEGIN …
and -----END …
boundaries are optional. They are required, however, if the private key is stored together with other data, for example the accompanying public key.
PKCS #1 formatted RSA private keys with boundaries (-----BEGIN RSA PRIVATE KEY-----
) are also supported.
See also
Last updated