public final class Encryption extends Object
Modifier and Type | Method and Description |
---|---|
static SecretKey |
createKey(Algorithm algorithm)
|
static String |
decrypt(Algorithm algorithm,
SecretKey secretKey,
int saltLength,
String encryptedValue)
|
static String |
encrypt(Algorithm algorithm,
SecretKey secretKey,
int saltLength,
String plainTextValue)
|
static Algorithm |
getFirstSupportedAlgorithm(Algorithm... algorithms) |
static boolean |
isAlgorithmSupported(Algorithm algorithm)
Checks if the given
Algorithm can be used to encrypt String-Values. |
static boolean |
isEncryptedValue(String mybeEncryptedValue)
Checks if the given String looks like an encrypted value.
|
static SecretKey |
readSecretKey(Algorithm algorithm,
String secretKeyBase64)
Read a
SecretKey from a base64 encoded String. |
static String |
toBase64String(SecretKey secretKey)
|
public static boolean isAlgorithmSupported(Algorithm algorithm)
Algorithm
can be used to encrypt String-Values.public static Algorithm getFirstSupportedAlgorithm(Algorithm... algorithms) throws IllegalArgumentException
algorithms
- a list of Algorithm
to checkAlgorithm
which can be used for encryption, see
isAlgorithmSupported(Algorithm)
.IllegalArgumentException
- if no Algorithm
is supported.public static SecretKey readSecretKey(Algorithm algorithm, String secretKeyBase64)
SecretKey
from a base64 encoded String.toBase64String(SecretKey)
public static boolean isEncryptedValue(String mybeEncryptedValue)
public static String encrypt(Algorithm algorithm, SecretKey secretKey, int saltLength, String plainTextValue)
Copyright © 2016–2019 Brabenetz Harald, Austria. All rights reserved.