refactored one-time-pad system and added modulus cheat sheet
This commit is contained in:
@@ -18,16 +18,16 @@ func OTPEncrypt(message string, key string) string {
|
||||
for n, c := range paddefinitions.NumToCharMap{
|
||||
if c == strings.ToUpper(char) {
|
||||
messagesplitint = append(messagesplitint, n)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for _, char := range keysplit {
|
||||
for n, c := range paddefinitions.NumToCharMap{
|
||||
if c == strings.ToUpper(char) {
|
||||
keysplitint = append(keysplitint, n)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func OTPEncrypt(message string, key string) string {
|
||||
if pos != 0 && pos % 5 == 0 {
|
||||
encryptedmessage = append(encryptedmessage, " ")
|
||||
}
|
||||
encryptedmessage = append(encryptedmessage, paddefinitions.NumToCharMap[(messagenum + keysplitint[pos]) % 35])
|
||||
encryptedmessage = append(encryptedmessage, paddefinitions.NumToCharMap[(messagenum + keysplitint[pos]) % 36])
|
||||
}
|
||||
|
||||
return (strings.Join(encryptedmessage, ""))
|
||||
|
||||
Reference in New Issue
Block a user