PGP Encryption of documents in Pega - Solution
Hi All,
we saw multiple people were looking for solution for implementing PGP encryption in Pega for documents.
Hi All, if you are looking for solution of PGP(Preety Good Privacy) Encryption of documents(PDF, Word, XML, CSV & etc) in Pega. Here is the solution. First of all you need Bouncy Castle Crypto library in Pega. if your already on 8.7 version then all the bouncy castle libraries are available in pega except "org.bouncycastle.util.io.Streams". we cretaed a java project for encryption and decryption using bouncy castle library. and created a jar for that which include this missing steram class as well. we have attached that jar file in attachments, please deploy the attached jar file in to your pega server. then create a library(PGPCryptoLibrary) and java function(EncryptionDecryption) in that library with 5 string parameters. Parametes decription is given below.
Encrypt String inputFileName = "Source File Location on Server with name and extension of file" String outputFileName = "Location where you want to put Encrypted file with name and extension on same server" String encKeyFileName = "Location of Public Key with name and extension of file on server" String passwd = "" -- No password required for Encryption String Mode = "Encrypt"
Decrypt String inputFileName = "Source Encrypted File Location on Server with name and extension of file" String outputFileName = "Path where you want to put decrypted file on same server" -- Only path is required as decryption function will decrypt the file with original file name. String encKeyFileName = "Location of Provate Key with name and extension of file on server" String passwd = "Password" – Password for Decryption String Mode = "Decrypt"
Then check the attached java code file in attachment and paste the code in "EncryptionDecryption" java function that you have already created. - Check the Function Ready to be Compiled Check box - Click on Test Function Compilation - Click on Generate Function - Click on Generate Library Now you can call this function any where and pass parameters according to your requirement.