Created
September 8, 2014 19:21
-
-
Save stefan2904/e76625b0ab5eed5aa8c7 to your computer and use it in GitHub Desktop.
JavaPrivacyGuard API v0.3 Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DecryptPGPMessage { | |
private static PGPMessage parseMessage(FileInputStream fis) throws Base64Exception, IOException, PGPException { | |
Base64CRC24InputStream in = new Base64CRC24InputStream(fis); | |
return new PGPMessage(in); | |
} | |
private static PGPPrivateKey parsePrivatekey(FileInputStream fis) throws Base64Exception, IOException, PGPException { | |
Base64CRC24InputStream in = new Base64CRC24InputStream(fis); | |
return new PGPPrivateKey(in); | |
} | |
public static void main(String[] args) throws Exception { | |
IAIK.addAsProvider(); | |
FileInputStream fis1 = new FileInputStream("demo/dsa.test.pgp"); | |
PGPMessage pgpmessage = parseMessage(fis1); | |
FileInputStream fis2 = new FileInputStream("demo/dsa.privkey.pgp"); | |
PGPPrivateKey privkey = parsePrivatekey(fis2); | |
pgpmessage.setDecryptionKey(privkey); | |
PGPData data = pgpmessage.doDecrypt(); | |
System.out.println(new String(ByteStreamHelper.inputStreamToByteArray(data.getDataStream()))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment