Skip to content

Instantly share code, notes, and snippets.

@canhnt
Created November 21, 2015 14:35
Show Gist options
  • Save canhnt/61603df13dbee49a83de to your computer and use it in GitHub Desktop.
Save canhnt/61603df13dbee49a83de to your computer and use it in GitHub Desktop.
final InputStream pubKeyStream = getClass().getClassLoader().getResourceAsStream("pubkey.asc");
assertNotNull(pubKeyStream);
PGPPublicKeyRingCollection pubRingCollection = new PGPPublicKeyRingCollection(
PGPUtil.getDecoderStream(pubKeyStream),
new JcaKeyFingerprintCalculator());
final PGPPublicKeyRing pgpPublicKeyRing = pubRingCollection.getKeyRings().next();
assertNotNull(pgpPublicKeyRing);
final PGPPublicKey pgpPublicKey = pgpPublicKeyRing.getPublicKey();
final JcaPGPKeyConverter converter = new JcaPGPKeyConverter();
PublicKey publicKey = converter.getPublicKey(pgpPublicKey);
assertNotNull(publicKey);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment