Package org.omnifaces.utils.security
Class MessageDigests
- java.lang.Object
-
- org.omnifaces.utils.security.MessageDigests
-
public final class MessageDigests extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
digest(byte[] message, byte[] salt, String algorithm)
static byte[]
digest(byte[] message, String algorithm)
static byte[]
digest(String message, byte[] salt, String algorithm)
static byte[]
digest(String message, String algorithm)
Calculate a message digest over a given string using the specified algorithm.static byte[]
digest(String message, Charset charset, byte[] salt, String algorithm)
static byte[]
digest(String message, Charset charset, String algorithm)
static MessageDigest
getMessageDigestInstance(String algorithm)
Returns aMessageDigest
instance that implements the specified digest algorithm.
-
-
-
Method Detail
-
getMessageDigestInstance
public static MessageDigest getMessageDigestInstance(String algorithm) throws UncheckedNoSuchAlgorithmException
Returns aMessageDigest
instance that implements the specified digest algorithm.This method calls
MessageDigest.getInstance(String)
, but wraps any potentialNoSuchAlgorithmException
s in aUncheckedNoSuchAlgorithmException
as this is an unrecoverable problem in most cases.- Parameters:
algorithm
- the name of the algorithm to use- Returns:
- a
MessageDigest
instance that implements the specified algorithm - Throws:
UncheckedNoSuchAlgorithmException
- if no implementation of the given algorithm is found
-
digest
public static byte[] digest(String message, String algorithm) throws UncheckedNoSuchAlgorithmException
Calculate a message digest over a given string using the specified algorithm. This method will useUTF_8
encoding.- Parameters:
message
- the message to calculate the digest overalgorithm
- the name of the algorithm- Returns:
- a byte array containing the message digest
- Throws:
UncheckedNoSuchAlgorithmException
- if no implementation of the given algorithm could be found
-
digest
public static byte[] digest(String message, Charset charset, String algorithm) throws UncheckedNoSuchAlgorithmException
-
digest
public static byte[] digest(String message, byte[] salt, String algorithm) throws UncheckedNoSuchAlgorithmException
-
digest
public static byte[] digest(String message, Charset charset, byte[] salt, String algorithm) throws UncheckedNoSuchAlgorithmException
-
digest
public static byte[] digest(byte[] message, String algorithm) throws UncheckedNoSuchAlgorithmException
-
digest
public static byte[] digest(byte[] message, byte[] salt, String algorithm) throws UncheckedNoSuchAlgorithmException
-
-