obfuscate

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package obfuscate centralizes redaction/obfuscation helpers used across the codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObfuscateTokenByPrefix

func ObfuscateTokenByPrefix(s string, prefix string) string

ObfuscateTokenByPrefix obfuscates tokens that follow a known prefix convention (e.g., "sk-"). If the string doesn't have the expected prefix, it falls back to the generic strategy. Behavior (kept for backward-compat with token.ObfuscateToken):

  • With prefix: keep the prefix, then show first 4 and last 4 of the remainder, replacing the middle with '*' If remainder <= 8, return the input unmodified
  • Without prefix: same result as ObfuscateTokenGeneric

func ObfuscateTokenGeneric

func ObfuscateTokenGeneric(s string) string

ObfuscateTokenGeneric obfuscates arbitrary token-like strings for display/logging. Behavior (kept for backward-compat with previous utils implementation): - length <= 4 → all asterisks of same length - 5..12 → keep first 2 characters, replace the rest with asterisks - > 12 → keep first 8 characters, then "...", then last 4 characters

func ObfuscateTokenSimple

func ObfuscateTokenSimple(s string) string

ObfuscateTokenSimple obfuscates token-like strings with a fixed pattern suitable for UIs. Behavior (kept for backward-compat with Admin template helper): - length <= 8 → "****" - > 8 → first 4 + "****" + last 4

Types

This section is empty.

Jump to

Keyboard shortcuts

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