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 caused by {}", e);
}
return hashRes;
}
暑期编程PK赛
得CSDN机械键盘等精美礼品!