This commit is contained in:
史悦
2025-08-13 19:03:20 +08:00
commit d62a2e9ed9
73 changed files with 7296 additions and 0 deletions

19
pkg/util/crypto.go Normal file
View File

@@ -0,0 +1,19 @@
package util
import (
"crypto/md5"
"fmt"
"ripper/pkg/crypto"
)
// CheckPassword 用于将用户输入的密码与数据库取出的密码进行比对
func CheckPassword(PlainText, SecretKey, CipherText string) bool {
chK, _ := crypto.AesEcrypt([]byte(PlainText), []byte(SecretKey))
return fmt.Sprintf("%x", md5.Sum(chK)) == CipherText
}
// CreatePassword 用于将用户输入的密码进行加密
func CreatePassword(SecretKey, PlainText string) string {
chK, _ := crypto.AesEcrypt([]byte(PlainText), []byte(SecretKey))
return fmt.Sprintf("%x", md5.Sum(chK))
}