redacted

Crates.ioredacted
lib.rsredacted
version0.2.0
sourcesrc
created_at2021-11-07 07:46:26.239949
updated_at2022-08-29 05:14:50.594937
descriptionWrappers to control debug formatting of potentially sensitive byte arrays
homepage
repositoryhttps://gitlab.com/thatonelutenist/redacted
max_upload_size
id477982
size25,386
Nathan McCarty (nmccarty)

documentation

https://docs.rs/redacted

README

Redacted

Library providing a transparent wrapper type for controlling [Debug] and [Display] behavior for potentially sensitive collections of bytes, including completely redacting them.

This library is intended to aid in controlling how sensitive types, such as cryptographic types, appear in logs, including being able to redact them entirely to prevent leaking sensitive information through debug output. However, it is more generally useful, and can also be used simply to force byte arrays to render as hex or the like in debug output.

Examples

Completely redact contents

use redacted::FullyRedacted;

let item = FullyRedacted::new(vec![0_u8; 32]);
let output = format!("{:?}", item);

assert_eq!(output, "[32 BYTES REDACTED]");

Render contents as hex

use redacted::{Redacted, formatter::FullHex};

let item: Redacted<_, FullHex> = Redacted::new(vec![0_u8; 8]);
let output = format!("{:?}", item);

assert_eq!(output, "0x0000000000000000");

Render contents as a truncated hex string

use redacted::{Redacted, formatter::TruncHex};

let item: Redacted<_, TruncHex<8>> = Redacted::new(vec![0_u8; 32]);
let output = format!("{:?}", item);

assert_eq!(output, "0x00000000...(32 bytes)");
Commit count: 0

cargo fmt