Shembull: Enkriptim/dekriptim me XOR

package main

import (
    "fmt"
)

func main() {
    text := "Google"
    key := "123"

    e := Xor(text, key)
    fmt.Println(text + " : " + e)

    d := Xor(e, key)
    fmt.Println(e + " : " + d)
}

func Xor(input, key string) (output string) {
    for i := 0; i < len(input); i++ {
        output += string(input[i] ^ key[i%len(key)])
    }
    return
}

https://play.golang.org/p/jvpwzyzjsCl

Rezultati:

Google : v]\V^V
v]\V^V : Google
All Rights Reserved Theme by 404 THEME.