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
+9.8k Golang : Get current, epoch time and display by year, month and day
+13.4k Golang : Generate Code128 barcode
+7.5k Golang : How to stop user from directly running an executable file?
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+6.7k Golang : Output or print out JSON stream/encoded data
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+40.5k Golang : Convert to io.ReadSeeker type
+4.1k Javascript : Empty an array example
+9k Golang : Capture text return from exec function example
+9.5k Golang : Accessing content anonymously with Tor
+8.2k Golang : Qt splash screen with delay example