org.dmonix.cipher
Class DataCipherer

java.lang.Object
  extended byorg.dmonix.cipher.DataCipherer

public abstract class DataCipherer
extends java.lang.Object

Utility class for encoding/decoding small amounts of data using ciphers.
The class is designed to encode/decode smaller amounts of data, e.g. strings that are to be stored on file or in a database.
The class can also encode/decode files.
If larger amounts of streamed data is to be encoded/decoded it is advised to use any of the sub classes to DMCipherInputStream and DMCipherOutputStream.

Copyright: Copyright (c) 2004

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Constructor Summary
DataCipherer()
           
 
Method Summary
 java.lang.Object clone()
          THIS METHOD IS NOT SUPPORTED!
static byte[] decodeDataDES(byte[] b, byte[] key)
          Decodes the data using the DES algorithm.
static byte[] decodeDataPBE(byte[] b, char[] key)
          Decodes the data using the PBEWithMD5AndDES algorithm.
static void decodeFileDES(java.io.File input, java.io.File output, byte[] key)
          Decodes a single file using the DES algorithm.
static void decodeFilePBE(java.io.File input, java.io.File output, char[] key)
          Decodes a single file using the PBE algorithm.
static byte[] encodeDataDES(byte[] b, byte[] key)
          Encodes the data using the DES algorithm.
static byte[] encodeDataPBE(byte[] b, char[] key)
          Encodes the data using the PBEWithMD5AndDES algorithm.
static void encodeFileDES(java.io.File input, java.io.File output, byte[] key)
          Encodes a file using the DES algorithm
static void encodeFilePBE(java.io.File input, java.io.File output, char[] key)
          Encodes a single file using the PBE algorithm.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataCipherer

public DataCipherer()
Method Detail

encodeDataDES

public static byte[] encodeDataDES(byte[] b,
                                   byte[] key)
                            throws java.io.IOException,
                                   java.security.GeneralSecurityException
Encodes the data using the DES algorithm.

Parameters:
b - The data to encode
key - The key for the cipher algoritm, must be exactly 8 bytes long (required by the algorithm)
Returns:
The encoded data
Throws:
java.io.IOException
java.security.GeneralSecurityException

encodeDataPBE

public static byte[] encodeDataPBE(byte[] b,
                                   char[] key)
                            throws java.io.IOException,
                                   java.security.GeneralSecurityException
Encodes the data using the PBEWithMD5AndDES algorithm.

Parameters:
b - The data to encode
key - The key for the cipher algoritm
Returns:
The encoded data
Throws:
java.io.IOException
java.security.GeneralSecurityException

decodeDataDES

public static byte[] decodeDataDES(byte[] b,
                                   byte[] key)
                            throws java.io.IOException,
                                   java.security.GeneralSecurityException
Decodes the data using the DES algorithm.

Parameters:
b - The data to decode
key - The key for the cipher algoritm, must be exactly 8 bytes long (required by the algorithm)
Returns:
The decoded data
Throws:
java.io.IOException
java.security.GeneralSecurityException

decodeDataPBE

public static byte[] decodeDataPBE(byte[] b,
                                   char[] key)
                            throws java.io.IOException,
                                   java.security.GeneralSecurityException
Decodes the data using the PBEWithMD5AndDES algorithm.

Parameters:
b - The data to decode
key - The key for the cipher algoritm
Returns:
The decoded data
Throws:
java.io.IOException
java.security.GeneralSecurityException

encodeFileDES

public static void encodeFileDES(java.io.File input,
                                 java.io.File output,
                                 byte[] key)
                          throws java.io.IOException,
                                 java.security.GeneralSecurityException
Encodes a file using the DES algorithm

Parameters:
input - The input file
output - The output file
key - The key, must be exactly 8 bytes long (required by the algorithm)
Throws:
java.io.IOException
java.security.GeneralSecurityException

encodeFilePBE

public static void encodeFilePBE(java.io.File input,
                                 java.io.File output,
                                 char[] key)
                          throws java.io.IOException,
                                 java.security.GeneralSecurityException
Encodes a single file using the PBE algorithm.

Parameters:
input - The input (original) file
output - The output (coded) file
key - The key to use for the encoding
Throws:
java.io.IOException
java.security.GeneralSecurityException
See Also:
DMCipherOutputStreamPBE

decodeFileDES

public static void decodeFileDES(java.io.File input,
                                 java.io.File output,
                                 byte[] key)
                          throws java.io.IOException,
                                 java.security.GeneralSecurityException
Decodes a single file using the DES algorithm.

Parameters:
input - The input (coded) file
output - The output (decoded) file
key - The key to use for the encoding, must be exactly 8 bytes long (required by the algorithm)
Throws:
java.io.IOException
java.security.GeneralSecurityException
See Also:
DMCipherInputStreamDES

decodeFilePBE

public static void decodeFilePBE(java.io.File input,
                                 java.io.File output,
                                 char[] key)
                          throws java.io.IOException,
                                 java.security.GeneralSecurityException
Decodes a single file using the PBE algorithm.

Parameters:
input - The input (coded) file
output - The output (decoded) file
key - The key to use for the encoding
Throws:
java.io.IOException
java.security.GeneralSecurityException
See Also:
DMCipherInputStreamPBE

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
THIS METHOD IS NOT SUPPORTED!
The method always throws java.lang.CloneNotSupportedException

Returns:
-
Throws:
java.lang.CloneNotSupportedException - The exception is always thrown


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.