decoder

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package decoder expands a chunk of bytes into the original plus any decoded variants worth re-scanning. Three encodings are inspected:

  • base64 (std + url-safe), runs of >=32 chars
  • percent-encoded sequences (%xx), when at least two are present
  • hex, runs of >=40 chars (covers SHA1/256 and key-shaped blobs)

Each variant is returned only when its decoded byte stream is mostly printable ASCII — a heuristic that filters out random-looking decoded noise such as binary blobs accidentally inside a base64 paragraph.

Variants() never returns the original twice, even if no decoder fired. Callers feed every returned slice through their detector pipeline so a secret hidden inside `Authorization: Bearer <base64-of-token>` is found the same way as one written in plaintext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Variant

type Variant struct {
	Source string
	Data   []byte
}

Variant pairs a decoded byte slice with the decoder that produced it. The original chunk uses Source="" so callers can branch on the empty string to detect "this is the unmodified input".

func Variants

func Variants(data []byte) []Variant

Variants returns the original chunk plus any decoded forms produced by inspecting data for embedded base64 / percent / hex runs. The original is always the first element so callers may iterate without a special case for "no decode applied".

Jump to

Keyboard shortcuts

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