Class CryptUtil
java.lang.Object
com.github.toolarium.security.util.CryptUtil
This is a simple util class for initialisation or checks.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncreateSecretKeySpec(byte[] key, String algorithm) Create a SecretKeySpeccreateSecretKeySpec(String keyString) Create a SecretKeySpecgetAlgorithmMessage(String provider, String algorithm) Prepare algorithm messageGet cipherGet cipherstatic CryptUtilGet the instanceintgetMaxAllowedKeyLength(String algorithm) Prepare algorithm max key lengthbooleanCheck if strong cryption is enabled or not
-
Field Details
-
ALGORITHM_AES
Represents the AES algorithm as string- See Also:
-
-
Method Details
-
getInstance
Get the instance- Returns:
- the instance
-
isStrongEncryptionEnabled
public boolean isStrongEncryptionEnabled()Check if strong cryption is enabled or not- Returns:
- true if strong cryption is enabled; otherwise false
-
getCipher
Get cipher- Parameters:
algorithm- the algorithm- Returns:
- the cipher object
- Throws:
GeneralSecurityException- in case of error
-
getCipher
Get cipher- Parameters:
provider- the provideralgorithm- the algorithm- Returns:
- the cipher object
- Throws:
GeneralSecurityException- in case of error
-
getAlgorithmMessage
Prepare algorithm message- Parameters:
provider- the provideralgorithm- the algorithm- Returns:
- the prepared message
-
getMaxAllowedKeyLength
Prepare algorithm max key length- Parameters:
algorithm- the algorithm- Returns:
- the prepared message
-
createSecretKeySpec
public SecretKeySpec createSecretKeySpec(String keyString) throws UnsupportedEncodingException, NoSuchAlgorithmException Create a SecretKeySpec- Parameters:
keyString- the key as string- Returns:
- the SecretKeySpec
- Throws:
UnsupportedEncodingException- In case of unsupported encodingNoSuchAlgorithmException- In case of invalid algorithm
-
createSecretKeySpec
Create a SecretKeySpec- Parameters:
key- the initial keyalgorithm- the algorithm- Returns:
- the SecretKeySpec
-