Top Description Fields Constructors Methods
org.bouncycastle.crypto.examples

public Class DESExample

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .BufferedReader, .FileInputStream, .FileNotFoundException, .FileOutputStream, .IOException, .InputStreamReader, java.security.SecureRandom, org.bouncycastle.crypto.CryptoException, .KeyGenerationParameters, org.bouncycastle.crypto.engines.DESedeEngine, org.bouncycastle.crypto.generators.DESedeKeyGenerator, org.bouncycastle.crypto.modes.CBCBlockCipher, org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher, org.bouncycastle.crypto.params.DESedeParameters, .KeyParameter, org.bouncycastle.util.encoders.Hex

DESExample is a simple DES based encryptor/decryptor.

The program is command line driven, with the input and output files specified on the command line.

java org.bouncycastle.crypto.examples.DESExample infile outfile [keyfile]
A new key is generated for each encryption, if key is not specified, then the example will assume encryption is required, and as output create deskey.dat in the current directory. This key is a hex encoded byte-stream that is used for the decryption. The output file is Hex encoded, 60 characters wide text file.

When encrypting;

When decrypting;

This example shows how to use the light-weight API, DES and the filesystem for message encryption and decryption.

Field Summary

Modifier and TypeField and Description
private PaddedBufferedBlockCipher
private boolean
private BufferedInputStream
private byte[]
private BufferedOutputStream

Constructor Summary

AccessConstructor and Description
public
public
DESExample(String infile, String outfile, String keyfile, boolean encrypt)

Method Summary

Modifier and TypeMethod and Description
public static void
main(String[] args)

private void
performDecrypt(byte[] key)

private void
performEncrypt(byte[] key)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cipherback to summary
private PaddedBufferedBlockCipher cipher
encryptback to summary
private boolean encrypt
inback to summary
private BufferedInputStream in
keyback to summary
private byte[] key
outback to summary
private BufferedOutputStream out

Constructor Detail

DESExampleback to summary
public DESExample()
DESExampleback to summary
public DESExample(String infile, String outfile, String keyfile, boolean encrypt)

Method Detail

mainback to summary
public static void main(String[] args)
performDecryptback to summary
private void performDecrypt(byte[] key)
performEncryptback to summary
private void performEncrypt(byte[] key)
processback to summary
private void process()