Skip to content

Commit

Permalink
Add keyCount as commandline arg
Browse files Browse the repository at this point in the history
  • Loading branch information
VladaSedlacek committed Mar 7, 2019
1 parent ae226fe commit d2e25eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gen-keys/generate_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ func main() {

algorithm := os.Args[1]
arg2 := os.Args[2]
arg3 := os.Args[3]

bitSize, err := strconv.Atoi(arg2)
if err != nil {
fmt.Printf("bitSize must be an integer and not %T!\n", arg2)
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)
Expand All @@ -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)
Expand Down

0 comments on commit d2e25eb

Please sign in to comment.