HDIV API 2.0.4

org.hdiv.cipher
Class CipherHTTP

java.lang.Object
  extended by org.hdiv.cipher.CipherHTTP
All Implemented Interfaces:
java.io.Serializable, ICipherHTTP

public class CipherHTTP
extends java.lang.Object
implements ICipherHTTP

The principal class related with cryptography. It has the responsability to encrypt and decrypt data.

Author:
Roberto Velasco
See Also:
Cipher, IvParameterSpec, Serialized Form

Constructor Summary
CipherHTTP()
           
 
Method Summary
 byte[] decrypt(byte[] data)
          Decrypts data in a single-part operation, or finishes a multiple-part operation.
 byte[] encrypt(byte[] data)
          Encrypts data in a single-part operation, or finishes a multiple-part operation.
 void init()
          Generates a Cipher object that implements the specified transformation.
 void initDecryptMode(Key key)
          Generates a Cipher object that implements the specified transformation, initializes cipher vector and initializes cipher to decryption mode with a key and a set of algorithm parameters.
 void initEncryptMode(Key key)
          Generates a Cipher object that implements the specified transformation, initializes cipher vector and initializes cipher to encryption mode with a key and a set of algorithm parameters.
 boolean isEncryptMode()
           
 void setEncryptMode(boolean encryptMode)
           
 void setProvider(java.lang.String provider)
           
 void setTransformation(java.lang.String transformation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CipherHTTP

public CipherHTTP()
Method Detail

init

public void init()
Generates a Cipher object that implements the specified transformation.


initEncryptMode

public void initEncryptMode(Key key)

Generates a Cipher object that implements the specified transformation, initializes cipher vector and initializes cipher to encryption mode with a key and a set of algorithm parameters.

The name of the transformation, e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Extension Reference Guide for information about standard transformation names.

Specified by:
initEncryptMode in interface ICipherHTTP
Parameters:
key - the encryption key
Throws:
HDIVException - if there is an initialization error.

initDecryptMode

public void initDecryptMode(Key key)
Generates a Cipher object that implements the specified transformation, initializes cipher vector and initializes cipher to decryption mode with a key and a set of algorithm parameters.

Specified by:
initDecryptMode in interface ICipherHTTP
Parameters:
key - the encryption key
Throws:
HDIVException - if there is an initialization error.

encrypt

public byte[] encrypt(byte[] data)
Encrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted depending on how this cipher was initialized.

The bytes in the input buffer, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in a new buffer.

if any exception is thrown, this cipher object may need to be reset before it can be used again.

Specified by:
encrypt in interface ICipherHTTP
Parameters:
data - The input buffer to encrypt
Returns:
The new buffer with the result
Throws:
HDIVException - if any exception is thrown in encryption process.

decrypt

public byte[] decrypt(byte[] data)
Decrypts data in a single-part operation, or finishes a multiple-part operation. The data is decrypted depending on how this cipher was initialized.

The bytes in the input buffer, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in a new buffer.

if any exception is thrown, this cipher object may need to be reset before it can be used again.

Specified by:
decrypt in interface ICipherHTTP
Parameters:
data - The input buffer to decrypt
Returns:
The new buffer with the result
Throws:
HDIVException - if any exception is thrown in decryption process.

setTransformation

public void setTransformation(java.lang.String transformation)
Parameters:
transformation - The transformation to set for the cipher factory bean.

setProvider

public void setProvider(java.lang.String provider)
Parameters:
provider - The provider to set.

isEncryptMode

public boolean isEncryptMode()

setEncryptMode

public void setEncryptMode(boolean encryptMode)

HDIV 2.0.4

Copyright © 2008 hdiv.org. All Rights Reserved.