There are times when you want to send information to another user but do not want anyone else but that user to be able to view the information. A way to achieve this is to use the "double key encryption system"- a Private Key and a Public Key. The Private Key is kept secret while the Public Key is distributed to the users that the information is intended for. To generate the encrypted key-pairs, use the 4D command GENERATE ENCRYPTION KEYPAIR. This command accepts 3 parameters. The first parameter is a blob to hold the Private Key. The second parameter is the blob to hold the Public Key. The third parameter is the key length in bits to generate. The third parameter is an option and is not required. If the third parameter is omitted, then the generated key size is 512 bits by default. If you use a key size of 1024 bits, you will need SLI128.
Below is an example of the code to generate the key-pairs:
GENERATE ENCRYPTION KEYPAIR($PrivateKey;$PublicKey)
BLOB TO DOCUMENT("PublicKey.txt";$PublicKey)
BLOB TO DOCUMENT("PrivateKey.txt";$PrivateKey)