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 OTPDecrypt(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)
}
}
}
@@ -39,7 +39,7 @@ func OTPDecrypt(message string, key string) string {
var decryptedmessage []string
for pos, messagenum := range messagesplitint{
decryptedmessage = append(decryptedmessage, paddefinitions.NumToCharMap[(((messagenum - keysplitint[pos]) % 35) + 35) % 35]) // crazy modulo for decryption
decryptedmessage = append(decryptedmessage, paddefinitions.NumToCharMap[(((messagenum - keysplitint[pos]) % 36) + 36) % 36]) // crazy modulo for decryption
}