mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
11 lines
288 B
Go
11 lines
288 B
Go
package abstract
|
|
|
|
import "crypto/subtle"
|
|
|
|
// Compares two strings (typicaly password hashes) in a secure, constant-time
|
|
// fashion. Returns true iff they are equal.
|
|
func SecureCompare(a, b string) bool {
|
|
ab := []byte(a)
|
|
bb := []byte(b)
|
|
return subtle.ConstantTimeCompare(ab, bb) == 1
|
|
}
|