postmoogle/vendor/github.com/etkecc/go-kit/utils.go

10 lines
296 B
Go

package kit
import "crypto/subtle"
// Eq checks if 2 strings are equal in constant time
func Eq(s1, s2 string) bool {
b1 := []byte(s1)
b2 := []byte(s2)
return subtle.ConstantTimeEq(int32(len(b1)), int32(len(b2))) == 1 && subtle.ConstantTimeCompare(b1, b2) == 1 //nolint:gosec // that's ok
}