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.5k Golang : Extract or copy items from map based on value
+5.6k PHP : Convert CSV to JSON with YQL example
+7.9k Swift : Convert (cast) String to Float
+5.9k Golang : Use NLP to get sentences for each paragraph example
+13.1k Golang : Convert(cast) uintptr to string example
+12.7k Golang : zlib compress file example
+7.6k Javascript : Push notifications to browser with Push.js
+15.3k nginx: [emerg] unknown directive "ssl"
+7.3k Golang : Of hash table and hash map
+18.6k Golang : Get download file size
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+12.8k Golang : Convert int(year) to time.Time type