Golang crypto/subtle.ConstantTimeSelect() function example
package crypto/subtle
ConstantTimeSelect returns x(2nd param) if v is 1 and y(3rd param) if v is 0. Its behavior is undefined if v(1st param) takes any other value.
Golang crypto/subtle.ConstantTimeSelect() function usage example
package main
import (
"fmt"
"crypto/subtle"
)
func main() {
x := 3
y := 4
n := subtle.ConstantTimeSelect(1,x,y) // v = 1
fmt.Printf("n : %d \n", n) // returns x
nn := subtle.ConstantTimeSelect(0,x,y) // v = 0
fmt.Printf("nn : %d \n", nn) // returns y
}
Output :
n : 3
nn : 4
Reference :
Advertisement
Something interesting
Tutorials
+16.5k Golang : Execute terminal command to remote machine example
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+7.4k Golang : Check to see if *File is a file or directory
+12.8k Golang : Convert int(year) to time.Time type
+10k Golang : Get escape characters \u form from unicode characters
+8.7k Golang : How to join strings?
+17.7k How to enable MariaDB/MySQL logs ?
+10.6k Golang : Allow Cross-Origin Resource Sharing request
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+13.9k Golang : Human readable time elapsed format such as 5 days ago
+14k Golang : Compress and decompress file with compress/flate example