SecretMasker

Utility object that masks secret values for safe display in logs, diagnostics, and configuration dumps.

Three masking strategies are supported (see MaskStrategy):

StrategyInputOutputDescription
MaskStrategy.FULL"superSecret""********"Replaces the entire value with asterisks.
MaskStrategy.PARTIAL"superSecret" (visibleChars=4)"supe********"Keeps the first N characters visible.
MaskStrategy.EDGES"superSecret""s**********t"Shows only the first and last character.

Empty strings always produce "********" regardless of strategy. Strings of length 2 or less under MaskStrategy.EDGES also produce "********" to avoid revealing the full value.

Since

1.0

See also

Functions

Link copied to clipboard
fun mask(value: String, strategy: MaskStrategy, visibleChars: Int): String

Masks a secret value according to the specified strategy.