Skip to main content

ToHex

Trait ToHex 

Source
pub trait ToHex {
    // Required methods
    fn to_hex(&self) -> String;
    fn to_hex_upper(&self) -> String;
    fn to_hex_zeroizing(&self) -> EncodedSecret;
    fn to_hex_upper_zeroizing(&self) -> EncodedSecret;
}
Expand description

Extension trait for encoding byte data as hexadecimal strings.

Requires feature encoding-hex.

Blanket-implemented for all AsRef<[u8]> types (byte slices, arrays, Vec<u8>). To encode a secret wrapper, call the inherent to_hex() method directly (ergonomically safest for single operations — no reference in the caller’s hands), or use with_secret(|b| b.to_hex()) for multi-step operations or when audit-greppability matters.

Required Methods§

Source

fn to_hex(&self) -> String

Encode bytes as lowercase hexadecimal.

Source

fn to_hex_upper(&self) -> String

Encode bytes as uppercase hexadecimal.

Source

fn to_hex_zeroizing(&self) -> EncodedSecret

Encode bytes as lowercase hexadecimal and wrap the result in crate::EncodedSecret.

Source

fn to_hex_upper_zeroizing(&self) -> EncodedSecret

Encode bytes as uppercase hexadecimal and wrap the result in crate::EncodedSecret.

Implementors§

Source§

impl<T: AsRef<[u8]> + ?Sized> ToHex for T

Available on crate features encoding-hex and alloc only.