mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-09 05:49:54 +00:00
21 lines
324 B
Go
21 lines
324 B
Go
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
|
|
}
|