refactored one-time-pad system and added modulus cheat sheet

This commit is contained in:
2025-10-19 15:52:50 -04:00
parent 3f8c8fc026
commit fd6272eca3
9 changed files with 44 additions and 44 deletions

View File

@@ -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, ""))