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
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+5.2k JavaScript/JQuery : Redirect page examples
+28k Golang : Move file to another directory
+13.3k Golang : Date and Time formatting
+9.4k Golang : Timeout example
+23.1k Golang : Randomly pick an item from a slice/array example
+7.8k Swift : Convert (cast) String to Double
+8.8k Golang : Accept any number of function arguments with three dots(...)
+30k Golang : Get time.Duration in year, month, week or day
+13.6k Golang : Get user input until a command or receive a word to stop
+35.3k Golang : Strip slashes from string example
+20.6k Golang : Secure(TLS) connection between server and client