Adjust some Go related things
This commit is contained in:
@@ -4,29 +4,28 @@ package otpgenerate
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
paddefinitions "dotp/pad_definitions"
|
||||
"math/big"
|
||||
"one-time-pad-utils/pad_definitions"
|
||||
)
|
||||
|
||||
|
||||
func GenerateOTP(chunks int) string {
|
||||
count := 1
|
||||
otpstring := ""
|
||||
|
||||
for count < (chunks*5)+1{
|
||||
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{
|
||||
if count%5 == 0 { // add a space every 5 characters, newline after 10 chunks
|
||||
if count%50 == 0 {
|
||||
otpstring += "\n"
|
||||
} else {
|
||||
otpstring += " "
|
||||
}
|
||||
}
|
||||
count+=1
|
||||
count += 1
|
||||
}
|
||||
|
||||
return otpstring
|
||||
|
||||
Reference in New Issue
Block a user