public class SunJceCrypt extends AbstractCrypt
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CRYPT_METHOD
Name of the default encryption method
|
static byte[] |
SALT
Salt
|
| Constructor and Description |
|---|
SunJceCrypt()
Constructor
|
SunJceCrypt(String cryptMethod)
Constructor that uses a custom encryption method (cipher).
|
| Modifier and Type | Method and Description |
|---|---|
protected Cipher |
createCipher(SecretKey key,
AlgorithmParameterSpec spec,
int mode)
Creates the
Cipher that will do the de-/encryption. |
protected KeySpec |
createKeySpec() |
protected AlgorithmParameterSpec |
createParameterSpec() |
protected byte[] |
crypt(byte[] input,
int mode)
Crypts the given byte array
|
protected SecretKey |
generateSecretKey()
Generate the de-/encryption key.
|
decryptUrlSafe, encryptUrlSafe, getKey, setKeypublic static final String DEFAULT_CRYPT_METHOD
public static final byte[] SALT
public SunJceCrypt()
public SunJceCrypt(String cryptMethod)
createKeySpec() and/or
createParameterSpec() for the custom cipher.cryptMethod - the name of encryption method (the cipher)protected byte[] crypt(byte[] input,
int mode)
throws GeneralSecurityException
crypt in class AbstractCryptinput - byte array to be encryptedmode - crypt modeGeneralSecurityExceptionprotected Cipher createCipher(SecretKey key, AlgorithmParameterSpec spec, int mode) throws GeneralSecurityException
Cipher that will do the de-/encryption.key - the secret key to usespec - the parameters spec to usemode - the mode (Cipher.ENCRYPT_MODE or Cipher.DECRYPT_MODE)GeneralSecurityExceptionprotected SecretKey generateSecretKey() throws NoSuchAlgorithmException, InvalidKeySpecException
Note: if you don't provide your own encryption key, the implementation will use a default. Be aware that this is potential security risk. Thus make sure you always provide your own one.
NoSuchAlgorithmException - unable to find encryption algorithm specifiedInvalidKeySpecException - invalid encryption keyprotected AlgorithmParameterSpec createParameterSpec()
protected KeySpec createKeySpec()
Copyright © 2006–2021 Apache Software Foundation. All rights reserved.