#cryptography #sensitive

redacted

Wrappers to control debug formatting of potentially sensitive byte arrays

9 releases

0.2.0 Aug 29, 2022
0.2.0-alpha.0 Nov 11, 2021
0.1.2 Nov 8, 2021
0.0.0 Nov 7, 2021

#146 in Value formatting

Download history 637/week @ 2024-07-22 668/week @ 2024-07-29 526/week @ 2024-08-05 464/week @ 2024-08-12 369/week @ 2024-08-19 253/week @ 2024-08-26 115/week @ 2024-09-02 184/week @ 2024-09-09 615/week @ 2024-09-16 489/week @ 2024-09-23 579/week @ 2024-09-30 233/week @ 2024-10-07 793/week @ 2024-10-14 618/week @ 2024-10-21 473/week @ 2024-10-28 417/week @ 2024-11-04

2,301 downloads per month
Used in 2 crates

0BSD license

17KB
388 lines

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)");

Dependencies

~225KB