From 3f37565c5fa17fdbed5b38ed1620d7e4e1633205 Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Fri, 16 Oct 2015 23:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80=E4=B8=8BXO?= =?UTF-8?q?R=E5=8A=A0=E5=AF=86=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dmy@lab --- tscipher/xor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tscipher/xor.go b/tscipher/xor.go index 19e9dcb..e34efab 100644 --- a/tscipher/xor.go +++ b/tscipher/xor.go @@ -9,7 +9,7 @@ type XOR struct { func (this *XOR) Decrypt(data []byte) (decrypted []byte, err error) { decrypted = make([]byte, len(data)) for i := 0; i < len(data); i++ { - decrypted[i] = data[i] ^ this.key[i%len(this.key)] + decrypted[i] = data[len(data)-i-1] ^ this.key[i%len(this.key)] } err = nil return @@ -18,7 +18,7 @@ func (this *XOR) Decrypt(data []byte) (decrypted []byte, err error) { func (this *XOR) Encrypt(data []byte) (encryped []byte, err error) { encryped = make([]byte, len(data)) for i := 0; i < len(data); i++ { - encryped[i] = data[i] ^ this.key[i%len(this.key)] + encryped[i] = data[len(data)-i-1] ^ this.key[i%len(this.key)] } err = nil return