From d2e25eb422ad36dacfeef1e9a946c15eef6c791a Mon Sep 17 00:00:00 2001 From: Vladimir Sedlacek Date: Thu, 7 Mar 2019 16:13:21 +0100 Subject: [PATCH] Add keyCount as commandline arg --- gen-keys/generate_keys.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gen-keys/generate_keys.go b/gen-keys/generate_keys.go index a962220..b9b94b7 100644 --- a/gen-keys/generate_keys.go +++ b/gen-keys/generate_keys.go @@ -18,6 +18,7 @@ func main() { algorithm := os.Args[1] arg2 := os.Args[2] + arg3 := os.Args[3] bitSize, err := strconv.Atoi(arg2) if err != nil { @@ -25,6 +26,12 @@ func main() { os.Exit(1) } + keyCount, err := strconv.Atoi(arg3) + if err != nil { + fmt.Printf("keyCount must be an integer and not %T!\n", arg3) + os.Exit(1) + } + // If the file doesn't exist, create it, or append to the file filename := fmt.Sprintf("%s%d.csv", algorithm, bitSize) f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) @@ -39,7 +46,7 @@ func main() { reader := rand.Reader - for id := 0; id < 10; id++ { + for id := 0; id < keyCount; id++ { start := time.Now() key, rsaerr := rsa.GenerateKey(reader, bitSize)