github.com/eagleql/xray-core@v1.4.4/transport/internet/kcp/xor.go (about)

     1  // +build !amd64
     2  
     3  package kcp
     4  
     5  // xorfwd performs XOR forwards in words, x[i] ^= x[i-4], i from 0 to len
     6  func xorfwd(x []byte) {
     7  	for i := 4; i < len(x); i++ {
     8  		x[i] ^= x[i-4]
     9  	}
    10  }
    11  
    12  // xorbkd performs XOR backwords in words, x[i] ^= x[i-4], i from len to 0
    13  func xorbkd(x []byte) {
    14  	for i := len(x) - 1; i >= 4; i-- {
    15  		x[i] ^= x[i-4]
    16  	}
    17  }