KCML_RSA_Encrypt

Purpose

Encrypt a string using an RSA public key

Definition

DEFSUB 'KCML_RSA_Encrypt(BYREF RSAPublicKey$, BYREF plaintext$, BYREF cyphertext$, BYREF error$) AS Bool

Parameters

RSAPublicKeyString containing PEM encoded RSA public key.
plaintextString to encrypt
cyphertextEncrypted result. This will be REDIMed to the size of the encrypted result.
errorIf the function fails then this parameter is REDIMmed to return an error string

Return

TRUE if the function succeeds. FALSE if the function fails, and error$ will contain an error string.

Description

This takes a PEM encoded RSA public key. It performs the asynchronous encryption of the plain text. You can only decrypt this text using the matching RSA private key. The process will generate a random symmetric key and encrypt the plain text with this symmetric key. The symmetric key is then encrypted using the supplied RSA public key. The cypher text is a combination of the encrypted key and encrypted text. This process currently relies on the OpenSSL libraries.

See also

Internal KCML Functions, Internally defined structures and Internally defined enumerations and constants.