public class PGPUtils extends Object
Utility to provide the following to BRIT API:
Derived from org.bouncycastle.openpgp.examples by seamans
| Modifier and Type | Method and Description |
|---|---|
static void |
decryptFile(InputStream encryptedInputStream,
OutputStream decryptedOutputStream,
InputStream keyInputStream,
char[] password)
Decrypt the passed in message stream
|
static void |
encryptFile(OutputStream armoredOut,
File inputFile,
org.bouncycastle.openpgp.PGPPublicKey encKey)
Encrypt a file
|
static org.bouncycastle.openpgp.PGPPrivateKey |
findPrivateKey(InputStream keyIn,
long keyID,
char[] pass)
Load a secret key ring collection from keyIn and find the secret key corresponding to
keyID if it exists.
|
static org.bouncycastle.openpgp.PGPPublicKey |
readPublicKey(InputStream in)
Load a PGP public key from a public keyring or ASCII armored text file
|
public static org.bouncycastle.openpgp.PGPPublicKey readPublicKey(InputStream in) throws IOException, org.bouncycastle.openpgp.PGPException
IOExceptionorg.bouncycastle.openpgp.PGPExceptionpublic static org.bouncycastle.openpgp.PGPPrivateKey findPrivateKey(InputStream keyIn, long keyID, char[] pass) throws IOException, org.bouncycastle.openpgp.PGPException, NoSuchProviderException
keyIn - input stream representing a key ring collection.keyID - keyID we want.pass - passphrase to decrypt secret key with.IOException - If the input stream has a problemorg.bouncycastle.openpgp.PGPException - If the data format is incorrectNoSuchProviderException - If the digest provider is not availablepublic static void decryptFile(InputStream encryptedInputStream, OutputStream decryptedOutputStream, InputStream keyInputStream, char[] password) throws IOException, org.bouncycastle.openpgp.PGPException, NoSuchProviderException
encryptedInputStream - The input streamdecryptedOutputStream - The output streamkeyInputStream - The key input streampassword - The credentialsIOException - If the input stream has a problemorg.bouncycastle.openpgp.PGPException - If the data format is incorrectNoSuchProviderException - If the digest provider is not availablepublic static void encryptFile(OutputStream armoredOut, File inputFile, org.bouncycastle.openpgp.PGPPublicKey encKey) throws IOException, NoSuchProviderException, org.bouncycastle.openpgp.PGPException
Encrypt a file
armoredOut - The output streaminputFile - The input fileencKey - The PGP public key for encryptingIOExceptionNoSuchProviderExceptionorg.bouncycastle.openpgp.PGPExceptionCopyright © 2015–2016. All rights reserved.