public class SymmetricEncryption extends Object
This new class allows symmetric encryption. You should have BouncyCastle installed. Three new configuration parameters could be added to the configuration:
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CIPHER_ALGORITHM |
static int |
DEFAULT_CIPHER_STRENGTH |
| Constructor and Description |
|---|
SymmetricEncryption()
New SymmetricEncryption object with default values.
|
SymmetricEncryption(EncryptionType encryption)
New SymmetricEncryption object.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
getAlgorithm()
Return the default supported algorithm to use.
|
static String |
getKeyPath()
Return the default filename of the key to use.
|
static int |
getStrength()
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.
|
public static final int DEFAULT_CIPHER_STRENGTH
public static final String DEFAULT_CIPHER_ALGORITHM
public SymmetricEncryption()
throws GeneralSecurityException
GeneralSecurityExceptionpublic SymmetricEncryption(EncryptionType encryption) throws GeneralSecurityException
encryption - the encryption required structureGeneralSecurityExceptionpublic byte[] encrypt(byte[] toEncrypt)
throws GeneralSecurityException
toEncrypt - GeneralSecurityExceptionpublic byte[] decrypt(byte[] toDecrypt)
throws GeneralSecurityException
toDecrypt - GeneralSecurityExceptionpublic boolean generateDefaultRandomKeyFile()
throws NoSuchAlgorithmException,
NoSuchProviderException
NoSuchAlgorithmExceptionNoSuchProviderExceptionpublic 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 strengthNoSuchAlgorithmExceptionNoSuchProviderExceptionpublic static String getKeyPath()
public static String getAlgorithm()
public static int getStrength()
public boolean initialize()
throws GeneralSecurityException
GeneralSecurityExceptionpublic static void main(String[] argv)
argv - Copyright © 2005-2017 LSC project. All Rights Reserved.