encode

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64

func Base64(data []byte) string

Base64 encodes data to standard base64.

func Base64Decode

func Base64Decode(s string) ([]byte, error)

Base64Decode decodes a standard base64 string.

func Base64Raw

func Base64Raw(data []byte) string

Base64Raw encodes data to base64 without padding.

func Base64URL

func Base64URL(data []byte) string

Base64URL encodes data to URL-safe base64.

func Hex

func Hex(data []byte) string

Hex encodes data to a hex string.

func HexDecode

func HexDecode(s string) ([]byte, error)

HexDecode decodes a hex string.

func JSON added in v0.2.0

func JSON(v any) string

JSON serializes a value to a JSON string.

func ROT13

func ROT13(s string) string

ROT13 applies ROT13 substitution cipher.

func URL

func URL(s string) string

URL percent-encodes a string.

func URLDecode

func URLDecode(s string) (string, error)

URLDecode decodes a percent-encoded string.

func URLPath

func URLPath(s string) string

URLPath encodes a string for use in a URL path segment.

func URLRaw

func URLRaw(s string) string

URLRaw percent-encodes a string preserving RFC 3986 unreserved characters. Unlike url.QueryEscape, it encodes spaces as %20 (not +) and only escapes characters that are not in: A-Z a-z 0-9 - _ . ~

func UTF16LE

func UTF16LE(s string) []byte

UTF16LE encodes a string to UTF-16 Little Endian bytes. Used for PowerShell -EncodedCommand.

func XOR

func XOR(data, key []byte) []byte

XOR applies XOR encryption with a repeating key.

Types

type Buffer added in v0.4.0

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a fluent binary packet builder with big-endian encoding. Designed for crafting protocol messages.

func NewBuffer added in v0.4.0

func NewBuffer() *Buffer

NewBuffer creates a new binary buffer.

func (*Buffer) Build added in v0.4.0

func (b *Buffer) Build() []byte

Build returns the buffer contents as a byte slice.

func (*Buffer) Byte added in v0.4.0

func (b *Buffer) Byte(v int) *Buffer

Byte appends a single byte.

func (*Buffer) Bytes added in v0.4.0

func (b *Buffer) Bytes(v []byte) *Buffer

Bytes appends raw bytes.

func (*Buffer) Len added in v0.4.0

func (b *Buffer) Len() int

Len returns the current buffer length.

func (*Buffer) NameList added in v0.4.0

func (b *Buffer) NameList(names ...string) *Buffer

NameList appends a comma-joined name list with 4-byte length prefix.

func (*Buffer) String added in v0.4.0

func (b *Buffer) String(s string) *Buffer

String appends a length-prefixed string: 4-byte big-endian length + data.

func (*Buffer) Uint16 added in v0.4.0

func (b *Buffer) Uint16(v int) *Buffer

Uint16 appends a big-endian uint16.

func (*Buffer) Uint16LE added in v0.4.0

func (b *Buffer) Uint16LE(v int) *Buffer

Uint16LE appends a little-endian uint16.

func (*Buffer) Uint32 added in v0.4.0

func (b *Buffer) Uint32(v int) *Buffer

Uint32 appends a big-endian uint32.

func (*Buffer) Uint32LE added in v0.4.0

func (b *Buffer) Uint32LE(v int) *Buffer

Uint32LE appends a little-endian uint32.

func (*Buffer) Uint64 added in v0.4.0

func (b *Buffer) Uint64(v int) *Buffer

Uint64 appends a big-endian uint64.

func (*Buffer) Zeroes added in v0.4.0

func (b *Buffer) Zeroes(n int) *Buffer

Zeroes appends n zero bytes.

Jump to

Keyboard shortcuts

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