public class PgpUtils
extends Object
Constructor and Description |
---|
PgpUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
decryptStream(InputStream in,
OutputStream out,
InputStream keyIn,
char[] passwd)
Decrypt input stream into output stream.
|
static String |
decryptStringWithPrivateKey(String message,
String secretKey,
String password)
Decrypt string.
|
static String |
decryptStringWithPrivateKeyFileName(String message,
String secretKeyFileName,
String password)
Decrypt string.
|
static String |
decryptStringWithPrivateKeyInInputStream(String message,
InputStream secretKey,
String password)
Decrypt string.
|
static void |
encryptFile(OutputStream out,
String fileName,
org.bouncycastle.openpgp.PGPPublicKey encKey,
boolean armor,
boolean withIntegrityCheck)
Encrypt file.
|
static void |
encryptStream(OutputStream out,
org.bouncycastle.openpgp.PGPPublicKey encKey,
InputStream streamData)
Encrypt stream.
|
static String |
encryptString(String message,
InputStream publicKeyInputStream)
Encrypt string.
|
static String |
encryptString(String message,
org.bouncycastle.openpgp.PGPPublicKey encKey)
Encrypt string.
|
static String |
encryptStringWithPublicKey(String message,
String publicKey)
Encrypt string.
|
static String |
encryptStringWithPublicKyeFileName(String message,
String publicKeyFileName)
Encrypt string.
|
static org.bouncycastle.openpgp.PGPPrivateKey |
findPrivateKey(InputStream keyIn,
long keyID,
char[] pass)
Load a secret key ring collection from keyIn and find the private key
corresponding to keyID if it exists.
|
static org.bouncycastle.openpgp.PGPPrivateKey |
findPrivateKey(org.bouncycastle.openpgp.PGPSecretKey pgpSecKey,
char[] pass)
Load a secret key and find the private key in it.
|
static boolean |
isForEncryption(org.bouncycastle.openpgp.PGPPublicKey key)
Checks if is for encryption.
|
static org.bouncycastle.openpgp.PGPPublicKey |
readPublicKey(InputStream in)
Read public key.
|
public static org.bouncycastle.openpgp.PGPPublicKey readPublicKey(InputStream in) throws IOException, org.bouncycastle.openpgp.PGPException
in
- the inIOException
- Signals that an I/O exception has occurred.org.bouncycastle.openpgp.PGPException
- the PGP exceptionpublic static void encryptStream(OutputStream out, org.bouncycastle.openpgp.PGPPublicKey encKey, InputStream streamData) throws IOException, org.bouncycastle.openpgp.PGPException
out
- the outencKey
- the enc keystreamData
- the stream dataIOException
- Signals that an I/O exception has occurred.org.bouncycastle.openpgp.PGPException
- the PGP exceptionpublic static void decryptStream(InputStream in, OutputStream out, InputStream keyIn, char[] passwd) throws Exception
in
- the inout
- the outkeyIn
- the key inpasswd
- the passwdException
- the exceptionpublic 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
- Signals that an I/O exception has occurred.org.bouncycastle.openpgp.PGPException
- the PGP exceptionNoSuchProviderException
- the no such provider exceptionpublic static org.bouncycastle.openpgp.PGPPrivateKey findPrivateKey(org.bouncycastle.openpgp.PGPSecretKey pgpSecKey, char[] pass) throws org.bouncycastle.openpgp.PGPException
pgpSecKey
- The secret keypass
- passphrase to decrypt secret key withorg.bouncycastle.openpgp.PGPException
- the PGP exceptionpublic static void encryptFile(OutputStream out, String fileName, org.bouncycastle.openpgp.PGPPublicKey encKey, boolean armor, boolean withIntegrityCheck) throws IOException, NoSuchProviderException, org.bouncycastle.openpgp.PGPException
out
- the outfileName
- the file nameencKey
- the enc keyarmor
- the armorwithIntegrityCheck
- the with integrity checkIOException
- Signals that an I/O exception has occurred.NoSuchProviderException
- the no such provider exceptionorg.bouncycastle.openpgp.PGPException
- the PGP exceptionpublic static String encryptString(String message, org.bouncycastle.openpgp.PGPPublicKey encKey) throws IOException, NoSuchProviderException, org.bouncycastle.openpgp.PGPException
message
- the messageencKey
- the enc keyarmor
- the armorwithIntegrityCheck
- the with integrity checkIOException
- Signals that an I/O exception has occurred.NoSuchProviderException
- the no such provider exceptionorg.bouncycastle.openpgp.PGPException
- the PGP exceptionpublic static String encryptStringWithPublicKyeFileName(String message, String publicKeyFileName) throws Exception
message
- the messagepublicKeyFileName
- the public key file nameException
public static String encryptStringWithPublicKey(String message, String publicKey) throws Exception
message
- the messagepublicKeyFileName
- the public key file nameException
public static String encryptString(String message, InputStream publicKeyInputStream) throws Exception
message
- the messagepublicKeyInputStream
- the public key input streamException
- the exceptionpublic static String decryptStringWithPrivateKeyFileName(String message, String secretKeyFileName, String password) throws Exception
message
- the messagesecretKeyFileName
- the secret key file namepassword
- the passwordException
- the exceptionpublic static String decryptStringWithPrivateKey(String message, String secretKey, String password) throws Exception
message
- the messagesecretKeyFileName
- the secret key file namepassword
- the passwordException
- the exceptionpublic static String decryptStringWithPrivateKeyInInputStream(String message, InputStream secretKey, String password) throws Exception
message
- the messagesecretKey
- the secret keypassword
- the passwordException
- the exceptionpublic static boolean isForEncryption(org.bouncycastle.openpgp.PGPPublicKey key)
key
- the keyCopyright © 2010-2020 Toolsverse. All Rights Reserved.