Wrap more errors

This commit is contained in:
2022-02-15 12:37:04 +00:00
parent 7a0c4a17a2
commit 74a53954de
3 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,10 @@
package bcrypt
import "golang.org/x/crypto/bcrypt"
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
// Verifier verifys passwords using Bcrypt
type Verifier struct {
@ -16,7 +20,7 @@ func (bv *Verifier) Verify(password string, hashOnDb string) error {
func (bv *Verifier) Hash(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bv.cost)
if err != nil {
return "", err
return "", fmt.Errorf("hash password: %w", err)
}
return string(hash[:]), nil