github.com/v2fly/v2ray-core/v4@v4.45.2/transport/internet/kcp/xor.go (about)

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