v0.1 - initial commit
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
package winpwn
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
// P16 packs a uint16 into a little-endian byte slice.
|
||||
func P16(val uint16) []byte {
|
||||
b := make([]byte, 2)
|
||||
binary.LittleEndian.PutUint16(b, val)
|
||||
return b
|
||||
}
|
||||
|
||||
// P32 packs a uint32 into a little-endian byte slice.
|
||||
func P32(val uint32) []byte {
|
||||
b := make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(b, val)
|
||||
return b
|
||||
}
|
||||
|
||||
// P64 packs a uint64 into a little-endian byte slice.
|
||||
func P64(val uint64) []byte {
|
||||
b := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(b, val)
|
||||
return b
|
||||
}
|
||||
|
||||
// U16 unpacks a little-endian uint16 from the first 2 bytes of b.
|
||||
func U16(b []byte) uint16 {
|
||||
return binary.LittleEndian.Uint16(b)
|
||||
}
|
||||
|
||||
// U32 unpacks a little-endian uint32 from the first 4 bytes of b.
|
||||
func U32(b []byte) uint32 {
|
||||
return binary.LittleEndian.Uint32(b)
|
||||
}
|
||||
|
||||
// U64 unpacks a little-endian uint64 from the first 8 bytes of b.
|
||||
func U64(b []byte) uint64 {
|
||||
return binary.LittleEndian.Uint64(b)
|
||||
}
|
||||
Reference in New Issue
Block a user