2024-01-03 09:56:10 +00:00
|
|
|
package utils
|
|
|
|
|
2024-01-17 15:10:53 +00:00
|
|
|
import "encoding/binary"
|
2024-01-17 14:42:41 +00:00
|
|
|
|
2024-01-17 15:10:53 +00:00
|
|
|
func EncodeEndian(value uint64, length int) []byte {
|
|
|
|
byteSlice := make([]byte, length)
|
|
|
|
binary.LittleEndian.PutUint64(byteSlice, value)
|
|
|
|
return byteSlice
|
2024-01-03 09:56:10 +00:00
|
|
|
}
|
|
|
|
|
2024-01-17 15:10:53 +00:00
|
|
|
func DecodeEndian(byteSlice []byte) uint64 {
|
|
|
|
buffer := make([]byte, 8)
|
|
|
|
copy(buffer, byteSlice)
|
2024-01-03 12:17:37 +00:00
|
|
|
|
2024-01-17 15:10:53 +00:00
|
|
|
return binary.LittleEndian.Uint64(buffer)
|
2024-01-03 09:56:10 +00:00
|
|
|
}
|