Win a copy of Head First Agile this week in the Agile forum!
    Bookmark Topic Watch Topic
  • New Topic

How to Decrypt the file already Encrypted by PGP tool  RSS feed

 
A P Rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Short: How to Decrypt the file which is already Encrypted by PGP tool by using Java.
Hi All,
Detail: I need a solution (but i don't know it was possible or not? ) I have some of the files with Encrypted by PGP third patry tool (ex:XXXXXX.pgp)and i have KeyFile called abc.skr(this file is combination of PrivateKey and Public Key). Now i want to Decrypt the file with Java progarmme. Can u please help me what exactly i suppose to do..?
Here my code:
try
{
FileInputStream keyfis = new FileInputStream ("D:\\punna_Decrypt\\classes\\abc.skr");// Keypair file reding
byte[] encKey = new byte[keyfis.available()];
keyfis.read(encKey);
// KeyPairGenerator generator = KeyPairGenerator.getInstance("DSA");
PKCS8EncodedKeySpec privKeySpec = new KCS8EncodedKeySpec(encKey);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
PrivateKey privKey = keyFactory.generatePrivate(privKeySpec);
// the Exception is:
java.security.spec.InvalidKeySpecException: Inappropriate key specification: invalid key format
I was new for security concepts, i gone through some of the cryptography doucements for gathering information but stil i was dylama... (
thax in advance
A P Rao deat
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is a duplicate of this post. I'm closing this one.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!