feat: create standalone native fnOS repository

This commit is contained in:
2026-10-02 15:19:09 +08:00
parent 69f3c30fab
commit 6725fc131d
492 changed files with 94023 additions and 3 deletions
+21
View File
@@ -0,0 +1,21 @@
package validate
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func BasicAuthPasswordHash(username, password string) (string, error) {
if err := Username(username); err != nil {
return "", err
}
if err := Password(password); err != nil {
return "", err
}
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil {
return "", fmt.Errorf("密码加密失败")
}
return string(hash), nil
}