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