finished all features
This commit is contained in:
34
Go/main.go
34
Go/main.go
@@ -3,29 +3,45 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"flag"
|
||||
"one-time-pad-utils/otp_gen"
|
||||
"math"
|
||||
"strings"
|
||||
"one-time-pad-utils/otp_generate"
|
||||
"one-time-pad-utils/otp_encrypt"
|
||||
"one-time-pad-utils/otp_decrypt"
|
||||
)
|
||||
|
||||
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")
|
||||
var decryptmessage = flag.String("decrypt", "", "Specify a message you wish to decrypt")
|
||||
var otpkey = flag.String("key", "", "The specify required key for encryption and decryption")
|
||||
var _ = encryptmessage
|
||||
var _ = decryptmessage
|
||||
var _ = otpkey
|
||||
var encryptmessage = flag.String("encrypt", "", "Specify a message you wish to encrypt (use quotes if you have spaces)")
|
||||
var decryptmessage = flag.String("decrypt", "", "Specify a message you wish to decrypt (use quotes if you have spaces)")
|
||||
var otpkey = flag.String("key", "", "The specify a key for encryption (optional) and decryption (required) (use quotes if you have spaces)")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *genpad {
|
||||
fmt.Printf("%v\n", otpgen.GenerateOTP(*genpadchunks))
|
||||
fmt.Printf("%v\n", otpgenerate.GenerateOTP(*genpadchunks))
|
||||
return
|
||||
}
|
||||
|
||||
if *encryptmessage != "" {
|
||||
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))
|
||||
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))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if *decryptmessage != "" {
|
||||
if *otpkey != ""{
|
||||
fmt.Printf("%v\n", otpdecrypt.OTPDecrypt(*decryptmessage,*otpkey))
|
||||
} else {
|
||||
fmt.Println("PLEASE SUPPLY A KEY")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user