Standard library / crypto/subtle
crypto/subtle.ConstantTimeSelect()
Select x if v is 1, otherwise y if v is 0. Other selector values are undefined. Expected stdout: '7 9\n'.
Formal Syntax & Structure
go syntaxgo
func ConstantTimeSelect(v, x, y int) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| v | int | Selector, exactly 0 or 1. |
| x | int | Value selected for 1. |
| y | int | Value selected for 0. |
Return Value
int
Selected value.
Working Example
Example Snippetgo
package main
import ( "crypto/subtle" "fmt")
func main() { fmt.Println(subtle.ConstantTimeSelect(1, 7, 9), subtle.ConstantTimeSelect(0, 7, 9)) }