Discussion
Virtusa
IN
Last activity: 17 Oct 2024 1:55 EDT
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.
-
Reply
-
Mandeep Rawat Phil Shannon Pavankumar A S -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
GB
Many thanks for your detailed post.
Also note that there may be a Marketplace offering which could help users looking for another method of encryption.
See my response in PGP encryption in pega for files
Toyota Financial Services
AU
Hi Vishant,
Hope you are doing well, I have tried to implement the above solution to encrypt and decrypt the file which is already in a location.
Imported the library and created the java function. I have passed the parameters as you suggested above. I am trying to encrypt a file which is in a file location and want to save the encrypted file in the same location with a different file name using the java function. I am getting file not found exception in the logs on new file name which I gave in the parameter as source output.
I have done this exercise using file data sets and it is working as expected. But, I want to try this using your customized solution in a activity.
Can you please help me here or anyone who has implemented this one.
Thanks in Advance.
Dileep
cognizant
CA
@DileepBalaga , I am facing same error.Did you find any solution for this?If so,can you let us know.
Toyota Financial Services
AU
Hi,
I have tried the solution which was mentioned by vishant and it did worked.
In the beginning I faced issues with Jar and Java code.. After multiple retry the code worked.
Please attach the error logs you are facing.
Thanks
Dileep Kumar Balaga
Virtusa
IN
Hi Jwala,
Please check the logs, you will get the exact error. please share the logs with us as well.
cognizant
CA
@VishantC , @DileepBalaga , I can only see below error.No additional error in logs
Error encrypting/decrypting filejava.io.FileNotFoundException: file:/web:/StaticContent/global/ServiceExport/test.txt
Toyota Financial Services
AU
Virtusa
IN
@DileepBalaga Most Welcome Dileep :) it was nice to work with you.
Virtusa
IN
I have attached the file.
cognizant
CA
@VishantC ,We couldn't make it work in cloud infrastructure as pega doesn't allow third party classes to access/create files in cloud location.Any idea,If anyone implemented PGP in pega cloud environments.