Package com.gmt2001.security
Class Digest
java.lang.Object
com.gmt2001.security.Digest
Helper to handle digesting a string
- Author:
- gmt2001
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compareSha256
(byte[] message, byte[] digest) Calculates a SHA-256 digest and compares it to an existing digeststatic boolean
compareSha256
(String message, String digest) Calculates a SHA-256 digest and compares it to an existing hex-encoded digeststatic byte[]
sha256
(byte[] message) Calculates a SHA-256 digeststatic String
Calculates a SHA-256 digest and returns the result as a hex-encoded string
-
Method Details
-
sha256
public static byte[] sha256(byte[] message) Calculates a SHA-256 digest- Parameters:
message
- The message to calculate the digest on- Returns:
- The calculated digest
-
sha256
Calculates a SHA-256 digest and returns the result as a hex-encoded string- Parameters:
message
- The message to calculate the digest on- Returns:
- The calculated digest as a hex-encoded string
-
compareSha256
public static boolean compareSha256(byte[] message, byte[] digest) Calculates a SHA-256 digest and compares it to an existing digest- Parameters:
message
- The message to calculate the digest ondigest
- The existing digest to compare to- Returns:
true
if the calculated digest ofmessage
is equal todigest
-
compareSha256
Calculates a SHA-256 digest and compares it to an existing hex-encoded digest- Parameters:
message
- The message to calculate the digest ondigest
- The existing hex-encoded digest to compare to- Returns:
true
if the calculated digest ofmessage
is equal todigest
-