diff --git a/blogserver/src/main/java/org/sang/config/MyPasswordEncoder.java b/blogserver/src/main/java/org/sang/config/MyPasswordEncoder.java new file mode 100644 index 0000000..34dd305 --- /dev/null +++ b/blogserver/src/main/java/org/sang/config/MyPasswordEncoder.java @@ -0,0 +1,19 @@ +package org.sang.config; + +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Component; +import org.springframework.util.DigestUtils; + + +@Component +public class MyPasswordEncoder implements PasswordEncoder { + @Override + public String encode(CharSequence rawPassword) { + return DigestUtils.md5DigestAsHex(rawPassword.toString().getBytes()); + } + + @Override + public boolean matches(CharSequence rawPassword, String encodedPassword) { + return encodedPassword.equals(DigestUtils.md5DigestAsHex(rawPassword.toString().getBytes())); + } +}