Adjust some Go related things
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package otpencrypt
|
||||
|
||||
import (
|
||||
paddefinitions "dotp/pad_definitions"
|
||||
"strings"
|
||||
"one-time-pad-utils/pad_definitions"
|
||||
)
|
||||
|
||||
func OTPEncrypt(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 OTPEncrypt(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,11 +38,11 @@ func OTPEncrypt(message string, key string) string {
|
||||
|
||||
var encryptedmessage []string
|
||||
|
||||
for pos, messagenum := range messagesplitint{
|
||||
if pos != 0 && pos % 5 == 0 {
|
||||
for pos, messagenum := range messagesplitint {
|
||||
if pos != 0 && pos%5 == 0 {
|
||||
encryptedmessage = append(encryptedmessage, " ")
|
||||
}
|
||||
encryptedmessage = append(encryptedmessage, paddefinitions.NumToCharMap[(messagenum + keysplitint[pos]) % 36])
|
||||
encryptedmessage = append(encryptedmessage, paddefinitions.NumToCharMap[(messagenum+keysplitint[pos])%36])
|
||||
}
|
||||
|
||||
return (strings.Join(encryptedmessage, ""))
|
||||
|
||||
Reference in New Issue
Block a user