Golang crypto/ecdsa.GenerateKey() function example
package crypto/ecdsa
GenerateKey generates a public and private key pair.
Golang crypto/ecdsa.GenerateKey() function usage example
pubkeyCurve := elliptic.P256() //see http://golang.org/pkg/crypto/elliptic/#P256
privatekey := new(ecdsa.PrivateKey)
privatekey, err := ecdsa.GenerateKey(pubkeyCurve, rand.Reader) // this generates a public & private key pair
if err != nil {
fmt.Println(err)
os.Exit(1)
}
var pubkey ecdsa.PublicKey
pubkey = privatekey.PublicKey
fmt.Println("Private Key :")
fmt.Printf("%x \n", privatekey)
fmt.Println("Public Key :")
fmt.Printf("%x \n",pubkey)
See ECDSA tutorial for full example
Reference :
Advertisement
Something interesting
Tutorials
+5.2k JavaScript/JQuery : Redirect page examples
+7.1k Golang : Get environment variable
+6.5k Grep : How to grep for strings inside binary data
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+5.6k Python : Print unicode escape characters and string
+14.5k Golang : Overwrite previous output with count down timer
+32.7k Golang : Regular Expression for alphanumeric and underscore
+9.2k Golang : Create and shuffle deck of cards example
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?