ch.elca.el4j.util.encryption
Class SymmetricEncryption

java.lang.Object
  extended by ch.elca.el4j.util.encryption.SymmetricEncryption

public class SymmetricEncryption
extends Object

Class to en- and decrypt data symetrically. CAVEAT: the encoding between byte[] and String was recently changed to adapt to the new Base64 encore (before it used a private method of sun).

Author:
Andreas Pfenninger (APR)
File-location:
SymmetricEncryption
Last check-in date:
2009-08-04 15:48:31 +0200 (Di, 04. Aug 2009) by swismer for revision 3884

Constructor Summary
SymmetricEncryption()
           
 
Method Summary
 String decrypt(String encryptedString)
          Decrypts a String.
 byte[] decryptStringToByteArray(String encryptedString)
          Decrypts a String into a byte array.
 String encrypt(String unencryptedString)
          Encrypts a String.
 String encryptByteArrayToString(byte[] cleartext)
          Encrypts a byte array into a String.
 void init()
          Initializes the encryptor.
 void setDataEncodingFormat(String dataEncodingFormat)
           
 void setEncryptionKey(String encryptionKey)
           
 void setEncryptionScheme(String encryptionScheme)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymmetricEncryption

public SymmetricEncryption()
Method Detail

setDataEncodingFormat

public void setDataEncodingFormat(String dataEncodingFormat)
Parameters:
dataEncodingFormat - The dataEncodingFormat to set.

setEncryptionKey

public void setEncryptionKey(String encryptionKey)
Parameters:
encryptionKey - The encryptionKey to set.

setEncryptionScheme

public void setEncryptionScheme(String encryptionScheme)
Parameters:
encryptionScheme - The encryptionScheme to set.

init

public void init()
          throws EncryptionException
Initializes the encryptor.

Throws:
EncryptionException - if encryption could not be initialized.

encrypt

public String encrypt(String unencryptedString)
               throws EncryptionException
Encrypts a String.

Parameters:
unencryptedString - The String to encrypt.
Returns:
The decrypted String.
Throws:
EncryptionException - if there was an error.

decrypt

public String decrypt(String encryptedString)
               throws EncryptionException
Decrypts a String.

Parameters:
encryptedString - The String to decrypt.
Returns:
The decrypted String.
Throws:
EncryptionException - if there was an error.

encryptByteArrayToString

public String encryptByteArrayToString(byte[] cleartext)
                                throws EncryptionException
Encrypts a byte array into a String.

Parameters:
cleartext - The byte array to encrypt.
Returns:
The encrypted String.
Throws:
EncryptionException - if there was an error.

decryptStringToByteArray

public byte[] decryptStringToByteArray(String encryptedString)
                                throws EncryptionException
Decrypts a String into a byte array.

Parameters:
encryptedString - The String to decrypt.
Returns:
The decrypted byte array.
Throws:
EncryptionException - if there was an error.


Copyright © 2005-2011 ELCA. All Rights Reserved.