feat(1.0): 初始化项目

This commit is contained in:
summer 2025-10-16 13:50:20 +08:00
parent 7c060c216a
commit c291afd38e
6 changed files with 5 additions and 9915 deletions

View File

@ -14,6 +14,4 @@ pass = 'api2api..'
user = 'root' user = 'root'
[jwt] [jwt]
admin_secret = "m9ycX9RTPyuYTWw9FrMm" admin_secret = "m9ycX9RTPyuYTWw9FrCc"
patient_secret = "p0yxX0RTPyuYTWw0FrPp"
doctor_secret = "d8ycC8RTPyuYTWw8FrDd"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ import (
// GenerateAdminHashedPassword [管理端]生成密码 // GenerateAdminHashedPassword [管理端]生成密码
func GenerateAdminHashedPassword(password string) (string, error) { func GenerateAdminHashedPassword(password string) (string, error) {
salt := "7M&7p7euU=MM" salt := "7M&7p7euU=CC"
passwordWithSalt := password + salt passwordWithSalt := password + salt
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(passwordWithSalt), bcrypt.DefaultCost) hashedPassword, err := bcrypt.GenerateFromPassword([]byte(passwordWithSalt), bcrypt.DefaultCost)
@ -30,51 +30,7 @@ func GenerateAdminHashedPassword(password string) (string, error) {
// VerifyAdminHashedPassword [管理端]验证密码 // VerifyAdminHashedPassword [管理端]验证密码
func VerifyAdminHashedPassword(hashedPassword, password string) bool { func VerifyAdminHashedPassword(hashedPassword, password string) bool {
salt := "7M&7p7euU=MM" salt := "7M&7p7euU=CC"
passwordWithSalt := password + salt
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword+salt), []byte(passwordWithSalt))
return err == nil
}
// GenerateDoctorHashedPassword [医生端]生成密码
func GenerateDoctorHashedPassword(password string) (string, error) {
salt := "9M&9p9euU=DD"
passwordWithSalt := password + salt
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(passwordWithSalt), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(hashedPassword), nil
}
// VerifyDoctorHashedPassword [医生端]验证密码
func VerifyDoctorHashedPassword(hashedPassword, password string) bool {
salt := "9M&9p9euU=DD"
passwordWithSalt := password + salt
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword+salt), []byte(passwordWithSalt))
return err == nil
}
// GeneratePatientHashedPassword [患者端]生成密码
func GeneratePatientHashedPassword(password string) (string, error) {
salt := "8T&8p8euU=PP"
passwordWithSalt := password + salt
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(passwordWithSalt), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(hashedPassword), nil
}
// VerifyPatientHashedPassword [患者端]验证密码
func VerifyPatientHashedPassword(hashedPassword, password string) bool {
salt := "8T&8p8euU=PP"
passwordWithSalt := password + salt passwordWithSalt := password + salt
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword+salt), []byte(passwordWithSalt)) err := bcrypt.CompareHashAndPassword([]byte(hashedPassword+salt), []byte(passwordWithSalt))

View File

@ -7,18 +7,8 @@ import (
) )
func TestGenerateAdminHashedPassword(t *testing.T) { func TestGenerateAdminHashedPassword(t *testing.T) {
t.Log(MD5("admin2025")) t.Log(MD5("chat2025"))
t.Log(GenerateAdminHashedPassword(MD5("admin2025"))) t.Log(GenerateAdminHashedPassword(MD5("chat2025")))
}
func TestGenerateDoctorHashedPassword(t *testing.T) {
t.Log(MD5("doctor2025"))
t.Log(GenerateDoctorHashedPassword(MD5("doctor2025")))
}
func TestGeneratePatientHashedPassword(t *testing.T) {
t.Log(MD5("patient2025"))
t.Log(GeneratePatientHashedPassword(MD5("patient2025")))
} }
func TestXorEncrypt(t *testing.T) { func TestXorEncrypt(t *testing.T) {