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 8655f8be97..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.md5DigestAsHex(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.md5DigestAsHex(email.getBytes()); + var emailHash = Hashing.sha256() + .hashString(email, java.nio.charset.StandardCharsets.UTF_8) + .toString(); if (specOwner.getAnnotations() == null) { specOwner.setAnnotations(new HashMap<>(2)); } diff --git a/application/src/test/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceIntegrationTest.java b/application/src/test/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceIntegrationTest.java index 463e5b0562..3e40d2f720 100644 --- a/application/src/test/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceIntegrationTest.java +++ b/application/src/test/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceIntegrationTest.java @@ -389,7 +389,7 @@ String fakeReplyJson() { "name":"", "displayName":"fake-display-name", "annotations":{ - "email-hash": "4249f4df72b475e7894fabed1c5888cf" + "email-hash": "4c05c58111251cebb0f0a452c5886a87425dd1bf24a9eb53ec92164f49f8d601" } }, "creationTime": "2024-03-11T06:23:42.923294424Z",