Standard library / crypto/subtle

crypto/subtle.ConstantTimeEq()

Compare two signed 32-bit integers. Functional tests are not timing or side-channel audits. Expected stdout: '1 0\n'.

Formal Syntax & Structure

go syntaxgo
func ConstantTimeEq(x, y int32) int

Parameters & Attributes

NameTypeDescription
xint32First operand.
yint32Second operand.

Return Value

int

1 for true and 0 for false.

Working Example

Example Snippetgo
package main
import (  "crypto/subtle"  "fmt")
func main() { fmt.Println(subtle.ConstantTimeEq(-7, -7), subtle.ConstantTimeEq(-7, 8)) }
Go Reference