mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-08-19 15:51:49 +00:00
Obfuscator interface in core & relay/proxy CLI support
This commit is contained in:
20
pkg/obfs/xor.go
Normal file
20
pkg/obfs/xor.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package obfs
|
||||
|
||||
type XORObfuscator []byte
|
||||
|
||||
func (x XORObfuscator) Deobfuscate(buf []byte, n int) int {
|
||||
l := len(x)
|
||||
for i := range buf {
|
||||
buf[i] ^= x[i%l]
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user