pub trait SecureEncoding {
// Required methods
fn to_hex(&self) -> HexString;
fn to_hex_upper(&self) -> String;
fn to_base64url(&self) -> Base64String;
fn try_to_bech32(
&self,
hrp: &str,
) -> Result<Bech32String, Bech32EncodingError>;
fn try_to_bech32m(
&self,
hrp: &str,
) -> Result<Bech32String, Bech32EncodingError>;
}Expand description
Re-export of SecureEncoding trait for convenient encoding extensions.
Re-export of the SecureEncoding trait.
Extension trait for safe, explicit encoding of secret byte data to strings.
All methods require the caller to first call .expose_secret() (or similar).
This makes every secret access loud, grep-able, and auditable.
For Bech32 encoding, use the trait methods with an HRP.
§Example
use secure_gate::{SecureEncoding, ExposeSecret};
let bytes = [0x42u8; 32];
let hex_string = bytes.to_hex();
let hex = hex_string.expose_secret(); // → "424242..."Required Methods§
Sourcefn to_hex_upper(&self) -> String
fn to_hex_upper(&self) -> String
Encode secret bytes as uppercase hexadecimal.
Sourcefn to_base64url(&self) -> Base64String
fn to_base64url(&self) -> Base64String
Encode secret bytes as URL-safe base64 (no padding).
Sourcefn try_to_bech32(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
fn try_to_bech32(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
Try to encode secret bytes as Bech32 with the specified HRP.
Sourcefn try_to_bech32m(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
fn try_to_bech32m(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
Try to encode secret bytes as Bech32m with the specified HRP.
Implementations on Foreign Types§
Source§impl SecureEncoding for [u8]
Available on crate features encoding-hex or encoding-base64 or encoding-bech32 only.
impl SecureEncoding for [u8]
Available on crate features
encoding-hex or encoding-base64 or encoding-bech32 only.fn to_hex(&self) -> HexString
fn to_hex_upper(&self) -> String
fn to_base64url(&self) -> Base64String
fn try_to_bech32(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
fn try_to_bech32m(&self, hrp: &str) -> Result<Bech32String, Bech32EncodingError>
Source§impl<const N: usize> SecureEncoding for [u8; N]
Available on crate features encoding-hex or encoding-base64 or encoding-bech32 only.
impl<const N: usize> SecureEncoding for [u8; N]
Available on crate features
encoding-hex or encoding-base64 or encoding-bech32 only.