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
+55.3k Golang : Unmarshal JSON from http response
+11k How to test Facebook App on localhost ?
+8.7k Golang : How to join strings?
+6.7k Golang : Output or print out JSON stream/encoded data
+20k Golang : How to run your code only once with sync.Once object
+8.2k Golang : Get final or effective URL with Request.URL example
+12.6k Golang : flag provided but not defined error
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+9.7k Golang : Eroding and dilating image with OpenCV example
+5.9k Unix/Linux : How to open tar.gz file ?
+29.2k Golang : missing Git command