Encrypt (PKE From LFN)

myPKEModule.Encrypt(inputData);

myPKEModuleThe name of the Public Key Encryption From LFN (Logical FileName) module structure
inputDataThe data to encrypt in DATA format
Return:Encrypted contents in DATA format

The Encrypt function encrypts the given inputData, using the options specified in the Public Key Encryption From LFN module definition.

Example:

IMPORT Std;

PublicKeyFile := '~Examples::certificates::public::pubkey.pem'; 
PrivateKeyFile:= '~Examples::certificates::private::privkey.pem'; 
       //You can restrict access using file scope security
       //on the ~Examples::certificates::private scope  

pubKey :=  RECORD
  STRING  Key;
END;

dPubKey :=  DATASET([{
'-----BEGIN PUBLIC KEY-----' + '\n' +
'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr64RncTp5pV0KMnWRAof' + '\n' +
'od+3AUS/IDngT39j3Iovv9aI2N8g4W5ipqhKftRESmzQ6I/TiUQcmi42soUXmCeE' + '\n' +
'BHqlMDydw9aHOQG17CB30GYsw3Lf8iZo7RC7ocQE3OcRzH0eBkOryW6X3efWnMoy' + '\n' +
'hIR9MexCldF+3WM/X0IX0ApSs7kuVPVG4Yj202+1FVO/XNwjMukJG5ASuxpYAQvv' + '\n' +
'/oKj6q7kInEIvhLiGfcm3bpTzWQ66zVz3z/huLbEXEy5oj2fQaC5E3s5mdpk/CW3' + '\n' +
'J6Tk4NY3NySWzE/2/ZOWxZdR79XC+goNL6v/5gPI8B/a3Z8OeM2PfSZwPMnVuvU0' + '\n' +
'bwIDAQAB' + '\n' +
'-----END PUBLIC KEY-----' + '\n'
}],pubKey);

OUTPUT(dPubKey,,PublicKeyFile, CSV(SEPARATOR(''), TERMINATOR('')), OVERWRITE);

PrivKey :=  RECORD
  STRING  Key;
END;
dPrivKey :=  DATASET([{
'-----BEGIN RSA PRIVATE KEY-----' + '\n' +
'MIIEowIBAAKCAQEAr64RncTp5pV0KMnWRAofod+3AUS/IDngT39j3Iovv9aI2N8g' + '\n' +
'4W5ipqhKftRESmzQ6I/TiUQcmi42soUXmCeEBHqlMDydw9a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4t7NmdHGqNxTV+jLvzBoQsrAoGAI+fOD+nz6znirYSpRe5D' + '\n' +
'tW67KtYxlr28+CcQoUaQ/Au5kjzE9/4DjXrT09QmVAMciNEnc/sZBjiNzFf525wv' + '\n' +
'wZP/bPZMVYKtbsaVkdlcNJranHGUrkzswbxSRzmBQ5/YmCWrDAuYcnhEqmMWcuU9' + '\n' +
'8jiS13JP9hOXlHDyIBYDhV0CgYBV6TznuQgnzp9NpQ/H8ijxilItz3lHTu4mLMlR' + '\n' +
'9mdAjMkszdLTg5uuE+z+N8rp17VUseoRjb3LvLG4+MXIyDbH/0sDdPm+IjqvCNDR' + '\n' +
'spmh9MgBh0JbsbWaZK0s9/qrI/FcSLZ04JLsfRmTPU/Y5y8/dHjYO6fDQhp44RZF' + '\n' +
'iCqNxQKBgHf7KZIOKgV4YNyphk1UYWHNz8YY5o7WtaQ51Q+kIbU8PRd9rqJLZyk2' + '\n' +
'tKf8e6z+wtKjxi8GKQzE/IdkQqiFmB1yEjjRHQ81WS+K5NnjN1t0IEscJqOAwv9s' + '\n' +
'iIhG5ueb6xoj/N0LuXa8loUT5aChKWxRHEYdegqU48f+qxUcJj9R' + '\n' +
'-----END RSA PRIVATE KEY-----' + '\n'
}],PrivKey);

OUTPUT(dPrivKey,,PrivateKeyFile, CSV(SEPARATOR(''), TERMINATOR('')), OVERWRITE);

//PKE Encryption module definition
MyPKEModule := STD.Crypto.PublicKeyEncryptionFromLFN('RSA', PublicKeyFile, PrivateKeyFile, '');

DATA encrypted := MyPKEModule.Encrypt((DATA)'The quick brown fox jumps over the lazy dog');
OUTPUT( (STRING)MyPKEModule.Decrypt(encrypted));