secure_gate/encoding/
base64_random_ext.rs

1#[cfg(feature = "rand")]
2use crate::traits::SecureEncoding;
3#[cfg(feature = "rand")]
4use crate::traits::expose_secret::ExposeSecret;
5
6#[cfg(feature = "rand")]
7impl crate::DynamicRandom {
8    /// Borrowing encode (original random remains usable).
9    pub fn to_base64url(&self) -> crate::encoding::base64::Base64String {
10        self.expose_secret().to_base64url()
11    }
12
13    /// Consuming encode (raw random bytes zeroized immediately).
14    pub fn into_base64url(self) -> crate::encoding::base64::Base64String {
15        self.expose_secret().to_base64url()
16    }
17}
18
19#[cfg(feature = "rand")]
20impl<const N: usize> crate::FixedRandom<N> {
21    /// Borrowing encode (original random remains usable).
22    pub fn to_base64url(&self) -> crate::encoding::base64::Base64String {
23        self.expose_secret().to_base64url()
24    }
25
26    /// Consuming encode (raw random bytes zeroized immediately).
27    pub fn into_base64url(self) -> crate::encoding::base64::Base64String {
28        self.expose_secret().to_base64url()
29    }
30}