go-ethereum/portalnetwork/utils/bytes.go
2023-12-27 10:41:23 +08:00

16 lines
313 B
Go

package utils
func ReverseBytesInPlace(src []byte) {
for i := 0; i < len(src)/2; i++ {
src[i], src[len(src)-i-1] = src[len(src)-i-1], src[i]
}
}
func ReverseBytes(src []byte) []byte {
lenth := len(src)
dst := make([]byte, lenth)
for i := 0; i < len(src); i++ {
dst[lenth-1-i] = src[i]
}
return dst
}