mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-08-13 21:01:46 +00:00
.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
21 lines
340 B
Go
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
|
|
}
|