bytes

package
v0.1.1-experimental.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAndReverseEndianess

func CopyAndReverseEndianess(input []byte) []byte

CopyAndReverseEndianess will copy the input byte slice and return the flipped version of it.

func ExtendToSize

func ExtendToSize(slice []byte, length int) []byte

ExtendToSize extends a byte slice to a specified length. It returns the original slice if it's already larger.

func PrependExtendToSize

func PrependExtendToSize(slice []byte, length int) []byte

PrependExtendToSize extends a byte slice to a specified length by prepending zero bytes. It returns the original slice if it's already larger.

func SafeCopy

func SafeCopy(src []byte) []byte

SafeCopy creates a copy of the provided byte slice. If the input slice is non-nil and has a length of 32 bytes, it assumes the slice represents a hash and copies it into a fixed-size array before returning a slice of that array. For other non-nil slices, it returns a dynamically allocated copy. If the input slice is nil, it returns nil.

func SafeCopy2D

func SafeCopy2D(src [][]byte) [][]byte

SafeCopy2D creates a copy of a two-dimensional byte slice. It iterates over the outer slice, copying each inner slice using SafeCopy. If the input is non-nil, it returns a copy of the two-dimensional slice. If the input is nil, it returns nil.

func ToBytes32

func ToBytes32(input []byte) [32]byte

ToBytes32 is a utility function that transforms a byte slice into a fixed 32-byte array. If the input exceeds 32 bytes, it gets truncated.

func ToBytes48

func ToBytes48(input []byte) [48]byte

ToBytes48 is a utility function that transforms a byte slice into a fixed 48-byte array. If the input exceeds 48 bytes, it gets truncated.

func ToBytes96

func ToBytes96(input []byte) [96]byte

ToBytes96 is a utility function that transforms a byte slice into a fixed 96-byte array. If the input exceeds 96 bytes, it gets truncated.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL