//One-Time Pad generator

package otpgenerate

import (
	"crypto/rand"
	"math/big"
	"one-time-pad-utils/pad_definitions"
)


func GenerateOTP(chunks int) string {
	count := 1
	otpstring := ""

	for count < (chunks*5)+1{
		n, err := rand.Int(rand.Reader, big.NewInt(36)) // generate new cryptographically secure random number
		if err != nil {
			panic(err)
		}
		otpstring += paddefinitions.NumToCharMap[int(n.Int64())] // print that number using the character map
		if count % 5 == 0 { // add a space every 5 characters, newline after 10 chunks
			if count % 50 == 0{
				otpstring += "\n"
			} else {
				otpstring += " "
			}
		}
		count+=1
	}

	return otpstring
}
