Skip to main content

redact_credential

Function redact_credential 

Source
pub fn redact_credential(credential: &str) -> String
Expand description

Redact a credential string for logging, showing first and last few characters.

This is useful for debugging while avoiding exposure of sensitive data. Format: AKIAIOSF***MPLE (first 8 + “***” + last 4)

Shows 8 characters at the start (useful since AWS keys always start with AKIA/ASIA) and 4 characters at the end. For short strings, shows only the first few with “***”.

§Security Note

This function should only be used for identifiers and tokens, never for secrets like aws_secret_access_key which should never be logged even in redacted form.