Revert "fix: need to use original endian functions from s5"
This reverts commit ae8bdbc272
.
This commit is contained in:
parent
ae8bdbc272
commit
a708380639
|
@ -1,21 +1,16 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
|
import "encoding/binary"
|
||||||
|
|
||||||
func EncodeEndian(value uint64, length int) []byte {
|
func EncodeEndian(value uint64, length int) []byte {
|
||||||
res := make([]byte, length)
|
byteSlice := make([]byte, length)
|
||||||
|
binary.LittleEndian.PutUint64(byteSlice, value)
|
||||||
for i := 0; i < length; i++ {
|
return byteSlice
|
||||||
res[i] = byte(value & 0xff)
|
|
||||||
value = value >> 8
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeEndian(bytes []byte) uint64 {
|
func DecodeEndian(byteSlice []byte) uint64 {
|
||||||
var total uint64
|
buffer := make([]byte, 8)
|
||||||
|
copy(buffer, byteSlice)
|
||||||
|
|
||||||
for i := 0; i < len(bytes); i++ {
|
return binary.LittleEndian.Uint64(buffer)
|
||||||
total += uint64(bytes[i]) << (8 * uint(i))
|
|
||||||
}
|
|
||||||
|
|
||||||
return total
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue