fix: revert again to using s5's original endian implementations

This commit is contained in:
Derrick Hammer 2024-01-24 10:58:05 -05:00
parent ba00e15518
commit 7ca0a67ba5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 15 additions and 11 deletions

View File

@ -1,16 +1,20 @@
package utils
import "encoding/binary"
func EncodeEndian(value uint64, length int) []byte {
byteSlice := make([]byte, length)
binary.LittleEndian.PutUint64(byteSlice, value)
return byteSlice
res := make([]byte, length)
for i := length - 1; i >= 0; i-- {
res[i] = byte(value & 0xff)
value = value >> 8
}
return res
}
func DecodeEndian(bytes []byte) uint64 {
var total uint64
for _, b := range bytes {
total = total*256 + uint64(b)
}
func DecodeEndian(byteSlice []byte) uint64 {
buffer := make([]byte, 8)
copy(buffer, byteSlice)
return binary.LittleEndian.Uint64(buffer)
return total
}