feat:平台账号

This commit is contained in:
苏竹红
2025-04-10 20:29:57 +08:00
parent f9219e028e
commit 080019ac0d
19 changed files with 111 additions and 41 deletions

View File

@@ -50,6 +50,7 @@ public class OpenSignatureUtil {
return hmacSha256(sb.toString(), appSecret);
}
private static String hmacSha256(String data, String key) {
try {
Mac sha256_HMAC = Mac.getInstance(HMAC_SHA256);

View File

@@ -20,7 +20,7 @@ public class PasswordUtil {
public static byte[] generateSalt() {
SecureRandom secureRandom = new SecureRandom();
// 16 字节的盐值
byte[] salt = new byte[16];
byte[] salt = new byte[3];
secureRandom.nextBytes(salt);
return salt;
}
@@ -50,12 +50,13 @@ public class PasswordUtil {
* @param salt 盐值
* @return 加密后的密码(十六进制字符串)
*/
public static String encryptPassword(String plainPassword, byte[] salt) {
public static String encryptPassword(String plainPassword, String salt) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
// 将盐值和明文密码拼接后进行哈希计算
messageDigest.update(salt);
byte[] hashedBytes = messageDigest.digest(plainPassword.getBytes());
String combined = plainPassword + salt;
byte[] hashedBytes = messageDigest.digest(combined.getBytes());
// 将字节数组转换为十六进制字符串
return bytesToHex(hashedBytes);