0
public static void doDecrypt(String source,String dest ){

    Runtime rt = Runtime.getRuntime();
    GPGDecrypt rte = new GPGDecrypt();
    Process proc;
    StreamWrapper error, output = null ;

    try {       

        proc = rt.exec("gpg --output "+dstfile +" --batch --passphrase "+ResourcePropertyManager.get("Passphrase")+ " --decrypt "+srcfile);

        System.out.println("After Passing");

        error = rte.getStreamWrapper(proc.getErrorStream(), "ERROR");

        output = rte.getStreamWrapper(proc.getInputStream(), "OUTPUT");

        int exitVal = 0;

        error.start();
        output.start();
        error.join(3000);
        output.join(3000);          
        exitVal = proc.waitFor();

        System.out.println("Output: " + output.message + "\nError: "+ error.message);

    } catch (IOException e) {
        System.out.println("IO "+e.getMessage());

        e.printStackTrace();
    } catch (InterruptedException e) {
        System.out.println("IEX"+e.getMessage());
        // TODO Auto-generated catch block
        e.printStackTrace();
    }   finally{
        rt = null;
        rte = null;
        proc = null;
        error = null;
        output = null;
    }
}

While passing the values dynamically through the above code the output file is not generated.

I am running this in windows.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Deepak
  • 1
  • 1
  • 2
    why are you using an external program instead of bouncycastle or some other crypto lib? – ciny Feb 10 '14 at 14:04
  • I am new to cryptography, just want to make my code simple as possible, can you share the links for bouncy castle code samples... i will try the crypto library if i am able to – Deepak Feb 11 '14 at 08:48
  • [this should probably get you started](http://stackoverflow.com/questions/14993223/getting-gpg-decryption-to-work-in-java-bouncy-castle) – ciny Feb 11 '14 at 11:55

0 Answers0