utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToNibbles added in v0.0.3

func BytesToNibbles(byts []byte) []byte

func CoalesceBytes added in v0.0.3

func CoalesceBytes(a []byte, others ...[]byte) []byte

func CoalesceString added in v0.0.3

func CoalesceString(a string, others ...string) string

func IndentString

func IndentString(text string, indentation string) string

func InvertBits added in v0.0.3

func InvertBits(data []byte) []byte

func NibblesToBytes added in v0.0.3

func NibblesToBytes(nibbles []byte) []byte

func NibblesToHex added in v0.0.3

func NibblesToHex(nibbles []byte) string

func Pad80 added in v0.0.3

func Pad80(data []byte, skipIfExact bool) []byte

Pad80 pads the data with byte 0x80 and then 0x00s until the data is an exact multiple of the block size.

`skipIfExact` controls if an entire block should be added when the data is an exact multiple of the block size or if the padding should be skipped entirely.

func PadLeft added in v0.0.3

func PadLeft(data []byte, padbyte byte, totalLength int) []byte

func PadRight added in v0.0.3

func PadRight(data []byte, padbyte byte, totalLength int) []byte

func ParseHexNibbles added in v0.0.3

func ParseHexNibbles(src string) ([]byte, error)

func SetNibble added in v0.0.3

func SetNibble(slice []byte, index int, nibble uint8)

func TruncateLeft added in v0.0.3

func TruncateLeft(data []byte, totalLength int) []byte

TruncateLeft discards bytes at the left until the length is equal the specified. If the length of the data is already equal to or shorter than `totalLength`, the data will be returned unchanged.

func TruncateRight added in v0.0.3

func TruncateRight(data []byte, totalLength int) []byte

TruncateRight discards bytes at the right until the length is equal the specified. If the length of the data is already equal to or shorter than `totalLength`, the data will be returned unchanged.

func XOR added in v0.0.3

func XOR(a []byte, others ...[]byte) []byte

XOR performs an Exclusive Or operation on the data and returns a slice with the results. This function does not mutate the slices fed into it.

If the length of `other` is smaller than the length of `a`, it will be padded to the left, adding zeroes to the left of b. If the length of `other` is greater than the length of `a`, it will be truncated to the left, removing the most significant bits.

func XORInPlace added in v0.0.3

func XORInPlace(data, other []byte)

XORInPlace performs an Exclusive Or operation on the data mutating it.

If the length of `other` is smaller than the length of `data`, it will be truncated to the left, removing the most significant bits. If the length of `other` is greater than the length of `data`, it will be padded to the left, adding zeroes to the left.

Types

This section is empty.

Jump to

Keyboard shortcuts

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