XOREncryption/Go/xor.go

12 lines
320 B
Go
Raw Normal View History

2016-07-09 13:34:05 +03:00
package xor
// EncryptDecrypt runs a XOR encryption on the input string, encrypting it if it hasn't already been,
// and decrypting it if it has, using the key provided.
func EncryptDecrypt(input, key string) (output string) {
for i := range input {
output += string(input[i] ^ key[i%len(key)])
}
return output
}