Golang crypto/dsa.Verify() function example
package crypto/dsa
Verify function verifies the signature using the given public key input against the hash and r,s integers. It reports whether the signature is valid.
Golang crypto/dsa.Verify() function usage example
var pubkey dsa.PublicKey
pubkey = privatekey.PublicKey
...
var h hash.Hash
h = md5.New()
r := big.NewInt(0)
s := big.NewInt(0)
io.WriteString(h, "This is the message to be signed and verified!")
signhash := h.Sum(nil)
r, s, err := dsa.Sign(rand.Reader, privatekey, signhash)
if err != nil {
fmt.Println(err)
}
// Verify
verifystatus := dsa.Verify(&pubkey, signhash, r, s)
fmt.Println(verifystatus) // should be true
See How to use DSA functions tutorial for more details
Reference :
Advertisement
Something interesting
Tutorials
+14.6k Golang : GUI with Qt and OpenCV to capture image from camera
+11.7k How to tell if a binary(executable) file or web application is built with Golang?
+17.4k Golang : Get future or past hours, minutes or seconds
+5.4k Golang *File points to a file or directory ?
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+8k Findstr command the Grep equivalent for Windows
+11k Golang : Create S3 bucket with official aws-sdk-go package
+5.4k How to check with curl if my website or the asset is gzipped ?
+14k Golang : Reverse IP address for reverse DNS lookup example
+5.5k Clean up Visual Studio For Mac installation failed disk full problem
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account