2021-05-05 05:06:05 +07:00
|
|
|
package oidc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/subtle"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Compare compares the hash with the data and returns an error if they don't match.
|
2022-04-07 12:33:53 +07:00
|
|
|
func (h PlainTextHasher) Compare(_ context.Context, hash, data []byte) (err error) {
|
2021-05-05 05:06:05 +07:00
|
|
|
if subtle.ConstantTimeCompare(hash, data) == 0 {
|
|
|
|
return errPasswordsDoNotMatch
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hash creates a new hash from data.
|
2022-04-07 12:33:53 +07:00
|
|
|
func (h PlainTextHasher) Hash(_ context.Context, data []byte) (hash []byte, err error) {
|
2021-05-05 05:06:05 +07:00
|
|
|
return data, nil
|
|
|
|
}
|