feat: add utils package

This commit is contained in:
Derrick Hammer 2024-01-03 04:56:10 -05:00
parent 834c964892
commit 50dd9251c2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 20 additions and 0 deletions

7
utils/bytes.go Normal file
View File

@ -0,0 +1,7 @@
package utils
import "bytes"
func ConcatBytes(slices ...[]byte) []byte {
return bytes.Join(slices, nil)
}

13
utils/endian.go Normal file
View File

@ -0,0 +1,13 @@
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 {
return binary.LittleEndian.Uint32(byteSlice)
}