memetic.crypto
Class DESCrypt

java.lang.Object
  extended by memetic.crypto.DESCrypt
All Implemented Interfaces:
Crypt

public class DESCrypt
extends java.lang.Object
implements Crypt

Encrypts and Decrypts using the DES Algorithm

Version:
1-1-alpha3
Author:
Andrew G D Rowley

Field Summary
static java.lang.String TYPE
          The DES encryption type
 
Constructor Summary
DESCrypt(java.lang.String password)
          Creates a new DESCrypt
 
Method Summary
 int decrypt(byte[] input, int offset, int length, byte[] output, int outOffset)
          Decrypts the input
 int encrypt(byte[] input, int offset, int length, byte[] output, int outOffset)
          Encrypts the input
 int getBlockSize()
          Returns the size of the block of the encryption or decryption
 int getDecryptOutputSize(int inputSize)
          Returns the maximum size the output buffer needs to be
 int getEncryptOutputSize(int inputSize)
          Returns the maximum size the output buffer needs to be
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE

public static final java.lang.String TYPE
The DES encryption type

See Also:
Constant Field Values
Constructor Detail

DESCrypt

public DESCrypt(java.lang.String password)
Creates a new DESCrypt

Parameters:
password - The password to crypt with
Method Detail

encrypt

public int encrypt(byte[] input,
                   int offset,
                   int length,
                   byte[] output,
                   int outOffset)
            throws javax.crypto.ShortBufferException,
                   javax.crypto.IllegalBlockSizeException,
                   javax.crypto.BadPaddingException
Description copied from interface: Crypt
Encrypts the input

Specified by:
encrypt in interface Crypt
Parameters:
input - The input to be encrypted
offset - The offset into the input buffer where the input starts
length - The length of the input
output - The output buffer
outOffset - The offset into the output buffer where to store the output
Returns:
The length of the output stored in the output buffer
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
javax.crypto.ShortBufferException
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
See Also:
Crypt.encrypt(byte[], int, int, byte[], int)

decrypt

public int decrypt(byte[] input,
                   int offset,
                   int length,
                   byte[] output,
                   int outOffset)
            throws javax.crypto.ShortBufferException,
                   javax.crypto.IllegalBlockSizeException,
                   javax.crypto.BadPaddingException
Description copied from interface: Crypt
Decrypts the input

Specified by:
decrypt in interface Crypt
Parameters:
input - The input to be decrypted
offset - The offset into the input buffer where the input starts
length - The length of the input
output - The output buffer
outOffset - The offset into the output buffer where to store the output
Returns:
The length of the output stored in the output buffer
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
javax.crypto.ShortBufferException
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
See Also:
Crypt.decrypt(byte[], int, int, byte[], int)

getEncryptOutputSize

public int getEncryptOutputSize(int inputSize)
Description copied from interface: Crypt
Returns the maximum size the output buffer needs to be

Specified by:
getEncryptOutputSize in interface Crypt
Parameters:
inputSize - The size of the input to be encrypted
Returns:
The maximum size of the output buffer
See Also:
Crypt.getEncryptOutputSize(int)

getDecryptOutputSize

public int getDecryptOutputSize(int inputSize)
Description copied from interface: Crypt
Returns the maximum size the output buffer needs to be

Specified by:
getDecryptOutputSize in interface Crypt
Parameters:
inputSize - The size of the input to be decrypted
Returns:
The maximum size of the output buffer
See Also:
Crypt.getDecryptOutputSize(int)

getBlockSize

public int getBlockSize()
Description copied from interface: Crypt
Returns the size of the block of the encryption or decryption

Specified by:
getBlockSize in interface Crypt
Returns:
The block size (in bytes)
See Also:
Crypt.getBlockSize()