Adjust some Go related things

This commit is contained in:
2025-10-29 16:22:55 -04:00
parent 9563ad252d
commit b8a4839196
8 changed files with 43 additions and 43 deletions

View File

@@ -1,16 +1,16 @@
package main
import (
"fmt"
otpdecrypt "dotp/otp_decrypt"
otpencrypt "dotp/otp_encrypt"
otpgenerate "dotp/otp_generate"
"flag"
"fmt"
"math"
"strings"
"one-time-pad-utils/otp_generate"
"one-time-pad-utils/otp_encrypt"
"one-time-pad-utils/otp_decrypt"
)
func main(){
func main() {
var genpad = flag.Bool("generate", false, "Generate a new One-Time Pad using CSPRNG")
var genpadchunks = flag.Int("chunks", 200, "Specify the amount of chunks to generate")
var encryptmessage = flag.String("encrypt", "", "Specify a message you wish to encrypt (use quotes if you have spaces)")
@@ -25,11 +25,11 @@ func main(){
}
if *encryptmessage != "" {
if *otpkey != ""{
fmt.Printf("%v\n", otpencrypt.OTPEncrypt(*encryptmessage,*otpkey))
if *otpkey != "" {
fmt.Printf("%v\n", otpencrypt.OTPEncrypt(*encryptmessage, *otpkey))
} else {
encryptmessagestring := strings.Replace(*encryptmessage, " ", "", -1)
lenofmessage := math.Ceil(float64(len(encryptmessagestring))/float64(5))
lenofmessage := math.Ceil(float64(len(encryptmessagestring)) / float64(5))
generated_key := otpgenerate.GenerateOTP(int(lenofmessage))
fmt.Printf("GENERATED NEW KEY SINCE NONE WAS SPECIFIED:\n%v\n\n%v\n", generated_key, otpencrypt.OTPEncrypt(*encryptmessage, generated_key))
}
@@ -37,13 +37,13 @@ func main(){
}
if *decryptmessage != "" {
if *otpkey != ""{
fmt.Printf("%v\n", otpdecrypt.OTPDecrypt(*decryptmessage,*otpkey))
if *otpkey != "" {
fmt.Printf("%v\n", otpdecrypt.OTPDecrypt(*decryptmessage, *otpkey))
} else {
fmt.Println("PLEASE SUPPLY A KEY")
}
return
}
flag.PrintDefaults()
}