refactor(all): change sql to postgresql

This commit is contained in:
merlin
2025-10-31 10:21:36 +08:00
parent 4f84603d82
commit e4f032a7f0
35 changed files with 154 additions and 587 deletions

View File

@@ -1,5 +1,6 @@
package xin.merlin.myblog_server.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.security.MessageDigest;
@@ -42,13 +43,14 @@ public class SHA256Util {
/**
* 使用用户ID生成盐值并对密码进行加密
* @param password 用户输入的密码
* @param userId 用户ID
* @return 加密后的密码哈希值
*/
public String encryptPassword(String password, String userId) {
// 先对用户ID进行SHA-256加密得到盐值
String salt = encryptSHA256(userId);
@Value("${jwt.salt}")
private String salt;
public String encryptPassword(String password) {
String s = encryptSHA256(salt);
// 将盐值与密码拼接后进行SHA-256加密
return encryptSHA256(salt +salt + password + salt);
return encryptSHA256(s +s + password + s);
}
}