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
+8.8k Yum Error: no such table: packages
+24k Golang : Find biggest/largest number in array
+10.6k Golang : Allow Cross-Origin Resource Sharing request
+19.3k Golang : Get host name or domain name from IP address
+11.4k Golang : Concatenate (combine) buffer data example
+10.9k Golang : How to transmit update file to client by HTTP request example
+7.5k Golang : How to handle file size larger than available memory panic issue
+13.2k Golang : How to calculate the distance between two coordinates using Haversine formula
+12k Golang : Decompress zlib file example
+10.1k Golang : Edge detection with Sobel method
+9.1k Golang : How to capture return values from goroutines?
+40.1k Golang : UDP client server read write example