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
+29.5k Golang : Login(Authenticate) with Facebook example
+8.3k Golang : Number guessing game with user input verification example
+4.6k Javascript : Detect when console is activated and do something about it
+9.9k Golang : Check if user agent is a robot or crawler example
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+15.9k Golang : Get current time from the Internet time server(ntp) example
+5.4k Javascript : How to loop over and parse JSON data?
+6.9k Mac/Linux/Windows : Get CPU information from command line
+5.8k Linux : Disable and enable IPv4 forwarding
+8.2k Android Studio : Rating bar example
+4.6k Mac OSX : Get disk partitions' size, type and name
+21.2k Golang : Get password from console input without echo or masked