Golang crypto/subtle.ConstantTimeByteEq() function example
package crypto/subtle
ConstantTimeByteEq returns 1 if x == y and 0 otherwise.
Golang crypto/subtle.ConstantTimeByteEq() function usage example
package main
import (
"crypto/subtle"
"fmt"
)
func main() {
X := uint8(1)
Y := uint8(2)
n := subtle.ConstantTimeByteEq(X,Y) // X != Y, n = 0
fmt.Printf("n : %d\n", n)
X = X + 1
nn := subtle.ConstantTimeByteEq(X,Y) // X == Y, nn = 1
fmt.Printf("nn : %d\n", nn)
}
Output :
n : 0
nn : 1
Reference :
Advertisement
Something interesting
Tutorials
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+46.2k Golang : Read tab delimited file with encoding/csv package
+12.3k Golang : 2 dimensional array example
+14.8k Golang : Normalize unicode strings for comparison purpose
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+7.2k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+14.3k Golang : Simple word wrap or line breaking example
+10.3k Golang : Wait and sync.WaitGroup example
+6.8k Swift : substringWithRange() function example
+7.5k Golang : Process json data with Jason package
+13.6k Golang : Query string with space symbol %20 in between