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
+6.6k Golang : Warp text string by number of characters or runes example
+13.8k Golang : Convert spaces to tabs and back to spaces example
+6.6k Golang : Totalize or add-up an array or slice example
+12.1k Golang : convert(cast) string to integer value
+7.1k Restart Apache or Nginx web server without password prompt
+4.8k Golang : A program that contain another program and executes it during run-time
+16.3k Golang :Trim white spaces from a string
+27.6k Golang : dial tcp: too many colons in address
+6.1k nginx : force all pages to be SSL
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+5.6k Swift : Get substring with rangeOfString() function example
+7.3k Golang : Of hash table and hash map