mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
commit
018dfe4920
@ -3,9 +3,9 @@ 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) {
|
||||
kL := len(key)
|
||||
for i := range input {
|
||||
output += string(input[i] ^ key[i%len(key)])
|
||||
output += string(input[i] ^ key[i%kL])
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user