Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用sha256代替MD5算法 #7088

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -172,7 +173,9 @@ private Mono<? extends CommentVo> 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));
}
Expand Down Expand Up @@ -224,7 +227,9 @@ private Mono<? extends ReplyVo> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down