Class CryptoDigestService
java.lang.Object
com.eurodyn.qlack.fuse.crypto.service.CryptoDigestService
Message digest algorithms.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongenerateSecureRandom
(int length) Generates a random seed.hmacSha256
(String secret, String message) HMAC with SHA256.Deprecated.Prefer the SHA256 alternatives.sha256
(InputStream inputStream) Calculates the SHA256 of theInputStream
.Calculates the SHA256 of the given string.
-
Constructor Details
-
CryptoDigestService
public CryptoDigestService()
-
-
Method Details
-
hmacSha256
public String hmacSha256(String secret, String message) throws NoSuchAlgorithmException, InvalidKeyException HMAC with SHA256.- Parameters:
secret
- the secret to usemessage
- the message to hash- Returns:
- the generated encoding
- Throws:
NoSuchAlgorithmException
- thrown when no algorithm is found for encryptionInvalidKeyException
- thrown when the provided key is invalid
-
sha256
Calculates the SHA256 of the given string.- Parameters:
message
- the message to hash- Returns:
- the SHA256 values
-
sha256
Calculates the SHA256 of theInputStream
.- Parameters:
inputStream
- the input stream to hash- Returns:
- the SHA256 value
- Throws:
IOException
- thrown when something unexpected happens
-
generateSecureRandom
Generates a random seed.- Parameters:
length
- the number of bytes of the seed. Note that this is *not* the length of the return value as the return value is Base64 encoded- Returns:
- a Base64 encoded version of the generated seed
- Throws:
NoSuchAlgorithmException
- thrown when no algorithm is found for encryption
-
md5
Deprecated.Prefer the SHA256 alternatives.Calculates the MD5 of the given string.- Parameters:
message
- The message to hash.
-