org.bouncycastle.crypto.examples
Class DESExample

java.lang.Object
  extended by org.bouncycastle.crypto.examples.DESExample

public class DESExample
extends java.lang.Object

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;

  • the infile is expected to be the 60 character wide base64 encoded file
  • the keyfile is expected to be a base64 encoded file

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


    Field Summary
    private  PaddedBufferedBlockCipher cipher
               
    private  boolean encrypt
               
    private  java.io.BufferedInputStream in
               
    private  byte[] key
               
    private  java.io.BufferedOutputStream out
               
     
    Constructor Summary
    DESExample()
               
    DESExample(java.lang.String infile, java.lang.String outfile, java.lang.String keyfile, boolean encrypt)
               
     
    Method Summary
    static void main(java.lang.String[] args)
               
    private  void performDecrypt(byte[] key)
               
    private  void performEncrypt(byte[] key)
               
    private  void process()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    encrypt

    private boolean encrypt

    cipher

    private PaddedBufferedBlockCipher cipher

    in

    private java.io.BufferedInputStream in

    out

    private java.io.BufferedOutputStream out

    key

    private byte[] key
    Constructor Detail

    DESExample

    public DESExample()

    DESExample

    public DESExample(java.lang.String infile,
                      java.lang.String outfile,
                      java.lang.String keyfile,
                      boolean encrypt)
    Method Detail

    main

    public static void main(java.lang.String[] args)

    process

    private final void process()

    performEncrypt

    private final void performEncrypt(byte[] key)

    performDecrypt

    private final void performDecrypt(byte[] key)