17 lines
405 B
Go
17 lines
405 B
Go
package shared
|
|
|
|
import (
|
|
"fmt"
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
// CheckPassword compares []byte password and []byte hash.
|
|
//
|
|
// Returns true if hashes match, false if not.
|
|
func CheckPassword(password []byte, hash []byte) bool {
|
|
fmt.Println(fmt.Sprintf("Hash: %v", hash))
|
|
fmt.Println(fmt.Sprintf("Hashlength: %v", len(hash)))
|
|
err := bcrypt.CompareHashAndPassword(hash, password)
|
|
|
|
return err == nil
|
|
}
|