Golang crypto/dsa.GenerateKey() function example
package crypto/dsa
GenerateKey generates a public&private key pair. The Parameters of the PrivateKey must already be valid (see GenerateParameters).
Golang crypto/dsa.GenerateKey() function usage example
params := new(dsa.Parameters)
// see http://golang.org/pkg/crypto/dsa/#ParameterSizes
if err := dsa.GenerateParameters(params, rand.Reader, dsa.L1024N160); err != nil {
fmt.Println(err)
os.Exit(1)
}
privatekey := new(dsa.PrivateKey)
privatekey.PublicKey.Parameters = *params
dsa.GenerateKey(privatekey, rand.Reader) // this generates a public & private key pair
See How to use DSA functions tutorial for more details
Reference :
Advertisement
Something interesting
Tutorials
+7.1k Golang : Get environment variable
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+20k Golang : How to run your code only once with sync.Once object
+28.6k Get file path of temporary file in Go
+6.9k Golang : Decode XML data from RSS feed
+13.7k Golang : Tutorial on loading GOB and PEM files
+8.4k Golang : How to check if input string is a word?
+32.2k Golang : Convert []string to []byte examples
+13.6k Golang : Qt progress dialog example
+7.5k Gogland : Single File versus Go Application Run Configurations
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+20.2k Golang : Convert seconds to human readable time format example