Skip to content

Commit

Permalink
feat(core): added some verify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 committed May 26, 2021
1 parent 2c500bc commit d99ce74
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions phc-crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,20 @@ func (a *Algo) Hash(plain string) (hash string, err error) {
}

// Hash returns a boolean of a hash function (that was initiated from Use)
func (a *Algo) Verify(hash, plain string) (bool, error) {
return false, nil
func (a *Algo) Verify(hash, plain string) (verify bool, err error) {
if a.Name == "scrypt" {
verify, err = scrypt.Verify(hash, plain)
return
} else if a.Name == "bcrypt" {
verify, err = bcrypt.Verify(hash, plain)
return
} else if a.Name == "argon2" {
verify, err = argon2.Verify(hash, plain)
return
}
verify = false
err = errors.New("the algorithm provided is not (yet) supported")
return
}

func in_array(val string, array []string) bool {
Expand Down

0 comments on commit d99ce74

Please sign in to comment.