Files
.github
cmd
docs
pkg
acl
auth
congestion
core
http
obfs
xor.go
xplus.go
xplus_test.go
relay
socks5
tproxy
transport
utils
.gitignore
ACL.md
ACL.zh.md
Dockerfile
LICENSE.md
README.md
README.zh.md
go.mod
go.sum
hysteria-dev/pkg/obfs/xor.go
2021-04-19 20:52:50 -07:00

21 lines
340 B
Go

package obfs
type XORObfuscator []byte
func (x XORObfuscator) Deobfuscate(in []byte, out []byte) int {
l := len(x)
for i := range in {
out[i] = in[i] ^ x[i%l]
}
return len(in)
}
func (x XORObfuscator) Obfuscate(p []byte) []byte {
np := make([]byte, len(p))
l := len(x)
for i := range p {
np[i] = p[i] ^ x[i%l]
}
return np
}