feat (user): add create

This commit is contained in:
dpurbosakti
2025-08-13 14:26:14 +07:00
parent 2e88eaf793
commit 7577c87f27
12 changed files with 342 additions and 9 deletions
+17
View File
@@ -0,0 +1,17 @@
package password
import (
"golang.org/x/crypto/bcrypt"
)
var Cost = 10 // can be set by consumer
func Hash(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), Cost)
return string(bytes), err
}
func Check(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}