From 8ad7ae8a3d8b950ed76c0686aae43b70cd3e3e92 Mon Sep 17 00:00:00 2001 From: cryptochecktool Date: Thu, 28 Nov 2024 10:39:26 +0800 Subject: [PATCH] Update CommentPublicQueryServiceImpl.java --- .../finders/impl/CommentPublicQueryServiceImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java b/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java index 1f06e3209e..f6bc85adf2 100644 --- a/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java +++ b/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Optional; import java.util.function.Function; +import com.google.common.hash.Hashing; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; @@ -172,7 +173,9 @@ private Mono filterCommentSensitiveData(CommentVo commentVo specOwner.setName(""); var email = owner.getEmail(); if (StringUtils.isNotBlank(email)) { - var emailHash = DigestUtils.sha256DigestAsHex(email.getBytes()); + var emailHash = Hashing.sha256() + .hashString(email, java.nio.charset.StandardCharsets.UTF_8) + .toString(); if (specOwner.getAnnotations() == null) { specOwner.setAnnotations(new HashMap<>(2)); } @@ -224,7 +227,9 @@ private Mono filterReplySensitiveData(ReplyVo replyVo) { specOwner.setName(""); var email = owner.getEmail(); if (StringUtils.isNotBlank(email)) { - var emailHash = DigestUtils.sha256DigestAsHex(email.getBytes()); + var emailHash = Hashing.sha256() + .hashString(email, java.nio.charset.StandardCharsets.UTF_8) + .toString(); if (specOwner.getAnnotations() == null) { specOwner.setAnnotations(new HashMap<>(2)); }