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) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | uint8 | First operand. |
| y | uint8 | Second 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)) }