From 235975bd23783f9e6a35ed331b5e942c4e263960 Mon Sep 17 00:00:00 2001 From: nexus166 Date: Mon, 2 Dec 2019 01:11:45 +0100 Subject: [PATCH] call len on key just once --- Go/xor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Go/xor.go b/Go/xor.go index bf029c1..ac82ecc 100644 --- a/Go/xor.go +++ b/Go/xor.go @@ -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 }