Easy way to Decrypt the "PGP encrypted file" using JAVA program.
Step1: Download below jars
1) bcpg-jdk14-145.jar
2) bcprov-ext-jdk14-145.jar
3) pgplib-2.5.jar
from http://www.softpedia.com/get/Programming/Components-Libraries/PGPLib.shtml and add them to class path (OR) Make sure the jars available to our java program.
Step 2: Use the below program for Decryption.
Java Program:
package pgplib;
import com.didisoft.pgp.PGPLib;
public class PGPSample {
public static void main(String[] args) throws Exception {
// initialize the library instance
PGPLib pgp = new PGPLib();
String privateKeyFile = "your .skr file path here";
String privateKeyPass = "your pass key here";
String originalFileName = pgp.decryptFile("your .pgp encrypted file path",
privateKeyFile, privateKeyPass, " your output file path");
}
}
Sample program:
package pgplib;
import com.didisoft.pgp.PGPLib;
public class PGPSample {
public static void main(String[] args) throws Exception {
// initialize the library instance
PGPLib pgp = new PGPLib();
String privateKeyFile = "c:\\secring.skr";
String privateKeyPass = "javacodehelp";
String originalFileName = pgp.decryptFile("c:\\abc.pgp",
privateKeyFile, privateKeyPass, "c:\\OUTPUT.txt");
}
}
Step1: Download below jars
1) bcpg-jdk14-145.jar
2) bcprov-ext-jdk14-145.jar
3) pgplib-2.5.jar
from http://www.softpedia.com/get/Programming/Components-Libraries/PGPLib.shtml and add them to class path (OR) Make sure the jars available to our java program.
Step 2: Use the below program for Decryption.
Java Program:
package pgplib;
import com.didisoft.pgp.PGPLib;
public class PGPSample {
public static void main(String[] args) throws Exception {
// initialize the library instance
PGPLib pgp = new PGPLib();
String privateKeyFile = "your .skr file path here";
String privateKeyPass = "your pass key here";
String originalFileName = pgp.decryptFile("your .pgp encrypted file path",
privateKeyFile, privateKeyPass, " your output file path");
}
}
Sample program:
package pgplib;
import com.didisoft.pgp.PGPLib;
public class PGPSample {
public static void main(String[] args) throws Exception {
// initialize the library instance
PGPLib pgp = new PGPLib();
String privateKeyFile = "c:\\secring.skr";
String privateKeyPass = "javacodehelp";
String originalFileName = pgp.decryptFile("c:\\abc.pgp",
privateKeyFile, privateKeyPass, "c:\\OUTPUT.txt");
}
}
I am doing this in scala and instead of adding library i am adding dependcies in .sbt file. Now i am unable to find dependency for pgplib2.5.jar or any other version of it. Can anybody suggest a solution.
ReplyDeletelet me portray the scenario: the file need to be pulled from a client server and processed/decrypted and sent to another server. If it was for local lib folder works fine. but i am forbidden to upload jars, can add dependency . Please suggest a solution.