org.lsc.utils
Class SecurityUtils

java.lang.Object
  extended by org.lsc.utils.SecurityUtils

public class SecurityUtils
extends Object

Provides some methods to encrypt, decrypt or hash data.

See Also:
SymmetricEncryption

Field Summary
static String HASH_MD5
           
static String HASH_SHA1
           
 
Constructor Summary
SecurityUtils()
           
 
Method Summary
static String decrypt(String value)
          Decrypt a base64 value.
static String encrypt(String value)
          Encrypt a value.
static String hash(String type, String value)
          Hash a value within a supported hash type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HASH_MD5

public static final String HASH_MD5
See Also:
Constant Field Values

HASH_SHA1

public static final String HASH_SHA1
See Also:
Constant Field Values
Constructor Detail

SecurityUtils

public SecurityUtils()
Method Detail

decrypt

public static String decrypt(String value)
                      throws GeneralSecurityException,
                             IOException
Decrypt a base64 value.

Parameters:
value - The value
Returns:
The decrypted String
Throws:
GeneralSecurityException
IOException

encrypt

public static String encrypt(String value)
                      throws GeneralSecurityException,
                             IOException
Encrypt a value.

Parameters:
value - The value
Returns:
The encrypted String, base64 encoded
Throws:
GeneralSecurityException
IOException

hash

public static String hash(String type,
                          String value)
                   throws NoSuchAlgorithmException
Hash a value within a supported hash type.

Parameters:
type - A valid hash type: SecurityUtils.HASH_MD5 or SecurityUtils.HASH_SHA1
value - A value to hash
Returns:
A valid base64 encoded hash
Throws:
NoSuchAlgorithmException


Copyright © 2005-2010 LSC project. All Rights Reserved.