|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.lsc.utils.security.SymmetricEncryption
public class SymmetricEncryption
This new class allows symmetric encryption. You should have BouncyCastle installed. Three new configuration parameters could be added to the configuration:
| Field Summary | |
|---|---|
static String |
DEFAULT_CIPHER_ALGORITHM
|
static int |
DEFAULT_CIPHER_STRENGTH
|
| Constructor Summary | |
|---|---|
SymmetricEncryption()
New SymmetricEncryption object with default values. |
|
SymmetricEncryption(String keyPath,
String algo,
int strength)
New SymmetricEncryption object. |
|
| Method Summary | |
|---|---|
byte[] |
decrypt(byte[] toDecrypt)
Decrypt bytes. |
byte[] |
encrypt(byte[] toEncrypt)
Encrypt bytes. |
boolean |
generateDefaultRandomKeyFile()
Generate a random key file with default value |
boolean |
generateRandomKeyFile(String keyPath,
String algo,
int strength)
Generate a random key file. |
static String |
getDefaultAlgorithm()
Return the default supported algorithm to use. |
static String |
getDefaultKeyPath()
Return the default filename of the key to use. |
static int |
getDefaultStrength()
Return the default encryption strength. |
boolean |
initialize()
Initialize encryption object from the configuration file. |
static void |
main(String[] argv)
This main allow user to generate random key file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_CIPHER_STRENGTH
public static final String DEFAULT_CIPHER_ALGORITHM
| Constructor Detail |
|---|
public SymmetricEncryption()
throws GeneralSecurityException
GeneralSecurityException
public SymmetricEncryption(String keyPath,
String algo,
int strength)
throws GeneralSecurityException
keyPath - The filename of the key to usealgo - A supported algorithm to use (see constant values defined
in this class which specified supported algorithms)strength - The encryption strength
GeneralSecurityException| Method Detail |
|---|
public byte[] encrypt(byte[] toEncrypt)
throws GeneralSecurityException
toEncrypt -
GeneralSecurityException
public byte[] decrypt(byte[] toDecrypt)
throws GeneralSecurityException
toDecrypt -
GeneralSecurityException
public boolean generateDefaultRandomKeyFile()
throws NoSuchAlgorithmException,
NoSuchProviderException
NoSuchAlgorithmException
NoSuchProviderException
public boolean generateRandomKeyFile(String keyPath,
String algo,
int strength)
throws NoSuchAlgorithmException,
NoSuchProviderException
keyPath - The filename where to write the keyalgo - The supported algorithm to usestrength - The encryption strength
NoSuchAlgorithmException
NoSuchProviderExceptionpublic static String getDefaultKeyPath()
public static String getDefaultAlgorithm()
public static int getDefaultStrength()
public boolean initialize()
throws GeneralSecurityException
GeneralSecurityExceptionpublic static void main(String[] argv)
argv -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||