Golang crypto/subtle.ConstantTimeLessOrEq() function example
package crypto/subtle
ConstantTimeLessOrEq returns 1 if x <= y and 0 otherwise. Its behavior is undefined if x(1st param) or y(2nd param) are negative or > 2**31 - 1.
Golang crypto/subtle.ConstantTimeLessOrEq() function usage example
package main
import (
"fmt"
"crypto/subtle"
)
func main() {
x := 3
y := 4
z := 1
n := subtle.ConstantTimeLessOrEq(x,y)
fmt.Printf("n : %d \n", n) // returns 1
nn := subtle.ConstantTimeLessOrEq(x,z)
fmt.Printf("nn : %d \n", nn) // returns 0
}
Output :
n : 1
nn : 0
Reference :
Advertisement
Something interesting
Tutorials
+5.4k Javascript : How to loop over and parse JSON data?
+29.9k Golang : Get and Set User-Agent examples
+20.9k PHP : Convert(cast) int to double/float
+11.3k Golang : How to use if, eq and print properly in html template
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+8.4k Golang : How to check if input string is a word?
+19.6k Golang : Close channel after ticker stopped example
+12.1k Golang : Pagination with go-paginator configuration example
+5k Golang : micron to centimeter example
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+5.9k Unix/Linux : How to open tar.gz file ?
+10.2k Golang : Use regular expression to get all upper case or lower case characters example