Standard library / crypto/subtle

crypto/subtle.ConstantTimeByteEq()

Compare two bytes for equality. Functional tests are not timing or side-channel audits. Expected stdout: '1 0\n'.

Formal Syntax & Structure

go syntaxgo
func ConstantTimeByteEq(x, y uint8) int

Parameters & Attributes

NameTypeDescription
xuint8First operand.
yuint8Second 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.ConstantTimeByteEq(7, 7), subtle.ConstantTimeByteEq(7, 8)) }
Go Reference