chore: init bj_power monorepo (dashboard/mes/wms/wms_client/workstation), clear subproject git metadata and align naming to folder names
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import "golang.org/x/crypto/bcrypt"
|
||||
|
||||
const bcryptCost = 10
|
||||
|
||||
func HashPassword(plain string) (string, error) {
|
||||
bytes, err := bcrypt.GenerateFromPassword([]byte(plain), bcryptCost)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
|
||||
func CheckPassword(plain, hashed string) bool {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hashed), []byte(plain)) == nil
|
||||
}
|
||||
Reference in New Issue
Block a user