2024-01-03 09:56:10 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "encoding/binary"
|
|
|
|
|
|
|
|
func EncodeEndian(value uint32, length int) []byte {
|
|
|
|
byteSlice := make([]byte, length)
|
|
|
|
binary.LittleEndian.PutUint32(byteSlice, value)
|
|
|
|
return byteSlice
|
|
|
|
}
|
|
|
|
|
|
|
|
func DecodeEndian(byteSlice []byte) uint32 {
|
2024-01-03 12:17:37 +00:00
|
|
|
buffer := make([]byte, 4)
|
|
|
|
copy(buffer, byteSlice)
|
|
|
|
|
|
|
|
return binary.LittleEndian.Uint32(buffer)
|
2024-01-03 09:56:10 +00:00
|
|
|
}
|