bytes

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

README

stdx/bytes

Import path: github.com/InsideGallery/core/stdx/bytes

Overview

stdx/bytes provides byte, bit, little-endian, XOR, CRC, rotation, and padding helpers.

Main APIs

  • GetByteLSB, GetBitLSB, LSBBytesToInt, and LSBBitValue work with least-significant-byte ordering.
  • LeftNibble, RightNibble, and UnsignedByteToInt extract byte parts and unsigned values.
  • XOR and XORAlt return XORed byte slices.
  • JamCRC32 returns the little-endian IEEE CRC-32 with all bits inverted.
  • RotateLeft and RotateRight rotate byte slices by the requested count.
  • PadMessageToBlocksize pads non-aligned messages with 0x80 followed by zero bytes.

Usage

crc := bytesx.JamCRC32([]byte("123456789"))
rotated := bytesx.RotateLeft([]byte{1, 2, 3, 4}, 1)
value := bytesx.LSBBytesToInt([]byte{0x34, 0x12})

_ = crc
_ = rotated
_ = value

Notes

The helpers do not read configuration. Functions that return slices allocate new result slices except PadMessageToBlocksize, which returns the original message when its length is already a multiple of the block size.

Documentation

Overview

Package stdx is a legacy aggregate of byte, strings, hash, context, password, and slice helpers.

New helpers should live in the package that owns the concept. Existing exports remain for compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBitLSB

func GetBitLSB(b byte, bit int) bool

func GetByteLSB

func GetByteLSB(value int64, byteNumber int) byte

func JamCRC32

func JamCRC32(value []byte) []byte

func LSBBitValue

func LSBBitValue(bitIdx int, isSet bool) byte

func LSBBytesToInt

func LSBBytesToInt(data []byte) int

func LeftNibble

func LeftNibble(input byte) int

func PadMessageToBlocksize

func PadMessageToBlocksize(message []byte, blocksize int) []byte

func RightNibble

func RightNibble(input byte) int

func RotateLeft

func RotateLeft(val []byte, rotations int) []byte

RotateLeft byte-rotates a byte array left by the given number of rotations

func RotateRight

func RotateRight(val []byte, rotations int) []byte

RotateRight byte-rotates a byte array left by the given number of rotations

func UnsignedByteToInt

func UnsignedByteToInt(b byte) int

func XOR

func XOR(a1, a2 []byte) []byte

func XORAlt

func XORAlt(a1, a2 []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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