Skip to main content

FromBase64UrlStr

Trait FromBase64UrlStr 

Source
pub trait FromBase64UrlStr {
    // Required method
    fn try_from_base64url(&self) -> Result<Vec<u8>, Base64Error>;
}
Expand description

Extension trait for decoding URL-safe base64 strings to byte data.

Input should be treated as untrusted; use fallible methods.

§Security Warning

Decoding input from untrusted sources should use fallible try_ methods. Invalid input may indicate tampering or errors.

§Example

use secure_gate::FromBase64UrlStr;
let base64_string = "QkJC";
let bytes = base64_string.try_from_base64url().unwrap();
// bytes is now Vec<u8>: [66, 66, 66]

Required Methods§

Source

fn try_from_base64url(&self) -> Result<Vec<u8>, Base64Error>

Fallibly decode a URL-safe base64 string to bytes.

Implementors§

Source§

impl<T: AsRef<str> + ?Sized> FromBase64UrlStr for T

Available on crate feature encoding-base64 only.