/**
* 获取字符串的 SHA256 摘要信息
*
* @param originalMessage 原始信息(字符串形式)
* @return String 64位摘要信息
*/
public static String getHashWithSHA256(String originalMessage) {
if (StringUtil.isEmpty(originalMessage)) {
throw new BusinessException(SystemErrorCode.DATA_OPERATION_LIMITED);
}
String hashRes = "";
try {
MessageDigest messageDigest = MessageDigest.getInstance(ConstantUtil.DEFAULT_DIGESTER_SHA256);
messageDigest.update(originalMessage.getBytes(StandardCharsets.UTF_8));
hashRes = ByteUtils.toHexString(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
LOGGER.error("No Such Algorithm Exception in method<HashUtil: getSHA256String> caused by {}", e);
}
return hashRes;
}