erigon-pulse/cl/persistence/base_encoding/primitives.go

18 lines
311 B
Go
Raw Normal View History

2023-10-18 21:10:53 +00:00
package base_encoding
import (
"encoding/binary"
2023-10-18 21:10:53 +00:00
)
func Encode64ToBytes4(x uint64) (out []byte) {
// little endian
out = make([]byte, 4)
binary.BigEndian.PutUint32(out, uint32(x))
return
}
func Decode64FromBytes4(buf []byte) (x uint64) {
// little endian
return uint64(binary.BigEndian.Uint32(buf))
}