Adjust some Go related things
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package otpdecrypt
|
||||
|
||||
import (
|
||||
paddefinitions "dotp/pad_definitions"
|
||||
"strings"
|
||||
"one-time-pad-utils/pad_definitions"
|
||||
)
|
||||
|
||||
func OTPDecrypt(message string, key string) string {
|
||||
message = strings.Replace(message, " ", "", -1)
|
||||
messagesplit := strings.Split(message,"")
|
||||
messagesplit := strings.Split(message, "")
|
||||
var messagesplitint []int
|
||||
|
||||
key = strings.Replace(key, " ", "", -1)
|
||||
keysplit := strings.Split(key,"")
|
||||
keysplit := strings.Split(key, "")
|
||||
var keysplitint []int
|
||||
|
||||
for _, char := range messagesplit {
|
||||
for n, c := range paddefinitions.NumToCharMap{
|
||||
for n, c := range paddefinitions.NumToCharMap {
|
||||
if c == strings.ToUpper(char) {
|
||||
messagesplitint = append(messagesplitint, n)
|
||||
|
||||
@@ -24,7 +24,7 @@ func OTPDecrypt(message string, key string) string {
|
||||
}
|
||||
|
||||
for _, char := range keysplit {
|
||||
for n, c := range paddefinitions.NumToCharMap{
|
||||
for n, c := range paddefinitions.NumToCharMap {
|
||||
if c == strings.ToUpper(char) {
|
||||
keysplitint = append(keysplitint, n)
|
||||
|
||||
@@ -38,8 +38,8 @@ func OTPDecrypt(message string, key string) string {
|
||||
|
||||
var decryptedmessage []string
|
||||
|
||||
for pos, messagenum := range messagesplitint{
|
||||
decryptedmessage = append(decryptedmessage, paddefinitions.NumToCharMap[(((messagenum - keysplitint[pos]) % 36) + 36) % 36]) // crazy modulo for decryption
|
||||
for pos, messagenum := range messagesplitint {
|
||||
decryptedmessage = append(decryptedmessage, paddefinitions.NumToCharMap[(((messagenum-keysplitint[pos])%36)+36)%36]) // crazy modulo for decryption
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user