- Added Server Configuration settings page (backend + frontend) - Added .env config download/import API - Runtime config updates via UI - Support for all 3 themes (default, air, berry) - i18n support (zh/en)
15 lines
425 B
Go
15 lines
425 B
Go
package common
|
|
|
|
import "golang.org/x/crypto/bcrypt"
|
|
|
|
func Password2Hash(password string) (string, error) {
|
|
passwordBytes := []byte(password)
|
|
hashedPassword, err := bcrypt.GenerateFromPassword(passwordBytes, bcrypt.DefaultCost)
|
|
return string(hashedPassword), err
|
|
}
|
|
|
|
func ValidatePasswordAndHash(password string, hash string) bool {
|
|
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
|
return err == nil
|
|
}
|