mirror of
https://github.com/rls-moe/nyx
synced 2024-10-06 13:52:07 +02:00
12 lines
288 B
Go
12 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
|
||
|
}
|