com.jalios.util
Class StringEncrypter

java.lang.Object
  extended by com.jalios.util.StringEncrypter

public class StringEncrypter
extends Object

Encrypts and decrypts string using Java Cryptography Extension (JCE)

Version:
$Revision: 33675 $
Author:
Javid Jamae - http://www.devx.com/Java/10MinuteSolution/21385

Nested Class Summary
static class StringEncrypter.EncryptionException
          Exception Wrapper for any error that might occur during the encryption or decryption process.
 
Field Summary
static String DES_ENCRYPTION_SCHEME
          DES encryption scheme.
static String DESEDE_ENCRYPTION_SCHEME
          DES3 (DESede) encryption scheme.
static String REVISION
           
 
Constructor Summary
StringEncrypter(String encryptionScheme, String encryptionKey)
          Create a new StringEncrypter using the specified encryption scheme and key.
 
Method Summary
 String decrypt(String encryptedString)
          Decrypt the specified string using this StringEncrypter.
 String encrypt(String unencryptedString)
          Encrypt the specified string using this StringEncrypter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

DESEDE_ENCRYPTION_SCHEME

public static final String DESEDE_ENCRYPTION_SCHEME
DES3 (DESede) encryption scheme.

See Also:
Constant Field Values

DES_ENCRYPTION_SCHEME

public static final String DES_ENCRYPTION_SCHEME
DES encryption scheme.

See Also:
Constant Field Values
Constructor Detail

StringEncrypter

public StringEncrypter(String encryptionScheme,
                       String encryptionKey)
                throws StringEncrypter.EncryptionException
Create a new StringEncrypter using the specified encryption scheme and key.

Parameters:
encryptionScheme - an encryption scheme from one of the following : DESEDE_ENCRYPTION_SCHEME or DES_ENCRYPTION_SCHEME
encryptionKey - the key to use for the encrypter, must be a valid string of 24 or more characters, must not be null.
Throws:
IllegalArgumentException - if encryptionKey is null or less than 24 characters
StringEncrypter.EncryptionException
Method Detail

encrypt

public String encrypt(String unencryptedString)
               throws StringEncrypter.EncryptionException
Encrypt the specified string using this StringEncrypter.

Parameters:
unencryptedString - the string to encrypt, must not be null or empty.
Returns:
the encrypted string.
Throws:
IllegalArgumentException - if unencryptedString is null or empty
StringEncrypter.EncryptionException

decrypt

public String decrypt(String encryptedString)
               throws StringEncrypter.EncryptionException
Decrypt the specified string using this StringEncrypter.

Parameters:
encryptedString - the string to decrypt, must not be null or empty.
Returns:
the decrypted string.
Throws:
IllegalArgumentException - if encryptedString is null or empty
StringEncrypter.EncryptionException


Copyright © 2001-2010 Jalios SA. All Rights Reserved.