Top Description Constructors Methods
org.bouncycastle.openpgp.examples

public Class KeyBasedFileProcessor

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.security.NoSuchProviderException, .SecureRandom, .Security, java.util.Iterator, org.bouncycastle.bcpg.ArmoredOutputStream, .CompressionAlgorithmTags, org.bouncycastle.jce.provider.BouncyCastleProvider, org.bouncycastle.openpgp.PGPCompressedData, .PGPEncryptedData, .PGPEncryptedDataGenerator, .PGPEncryptedDataList, .PGPException, .PGPLiteralData, .PGPOnePassSignatureList, .PGPPrivateKey, .PGPPublicKey, .PGPPublicKeyEncryptedData, .PGPSecretKeyRingCollection, .PGPUtil, org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory, org.bouncycastle.openpgp.operator.PGPDataEncryptorBuilder, org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator, .JcePGPDataEncryptorBuilder, .JcePublicKeyDataDecryptorFactoryBuilder, .JcePublicKeyKeyEncryptionMethodGenerator, org.bouncycastle.util.io.Streams

A simple utility class that encrypts/decrypts public key based encryption files.

To encrypt a file: KeyBasedFileProcessor -e [-a|-ai] fileName publicKeyFile.
If -a is specified the output file will be "ascii-armored". If -i is specified the output file will be have integrity checking added.

To decrypt: KeyBasedFileProcessor -d fileName secretKeyFile passPhrase.

Note 1: this example will silently overwrite files, nor does it pay any attention to the specification of "_CONSOLE" in the filename. It also expects that a single pass phrase will have been used.

Note 2: if an empty file name has been specified in the literal data object contained in the encrypted packet a file with the name filename.out will be generated in the current working directory.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
decryptFile(String inputFileName, String keyFileName, char[] passwd, String defaultFileName)

private static void
decryptFile(InputStream in, InputStream keyIn, char[] passwd, String defaultFileName)

decrypt the passed in message stream

private static void
encryptFile(String outputFileName, String inputFileName, String encKeyFileName, boolean armor, boolean withIntegrityCheck)

private static void
encryptFile(OutputStream out, String fileName, PGPPublicKey encKey, boolean armor, boolean withIntegrityCheck)

public static void
main(String[] args)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KeyBasedFileProcessorback to summary
public KeyBasedFileProcessor()

Method Detail

decryptFileback to summary
private static void decryptFile(String inputFileName, String keyFileName, char[] passwd, String defaultFileName) throws IOException, NoSuchProviderException
decryptFileback to summary
private static void decryptFile(InputStream in, InputStream keyIn, char[] passwd, String defaultFileName) throws IOException, NoSuchProviderException

decrypt the passed in message stream

encryptFileback to summary
private static void encryptFile(String outputFileName, String inputFileName, String encKeyFileName, boolean armor, boolean withIntegrityCheck) throws IOException, NoSuchProviderException, PGPException
encryptFileback to summary
private static void encryptFile(OutputStream out, String fileName, PGPPublicKey encKey, boolean armor, boolean withIntegrityCheck) throws IOException, NoSuchProviderException
mainback to summary
public static void main(String[] args) throws Exception