Function base64::encode_engine

source ·
pub fn encode_engine<E: Engine, T: AsRef<[u8]>>(input: T, engine: &E) -> String
Expand description

Encode arbitrary octets as base64 using the provided Engine. Returns a String.

Example

const URL_SAFE_ENGINE: base64::engine::fast_portable::FastPortable =
    base64::engine::fast_portable::FastPortable::from(
        &base64::alphabet::URL_SAFE,
        base64::engine::fast_portable::NO_PAD);

    let b64 = base64::encode_engine(
        b"hello world~",
        &base64::engine::DEFAULT_ENGINE
        );
    println!("{}", b64);

    let b64_url = base64::encode_engine(
        b"hello internet~",
        &URL_SAFE_ENGINE
        );
    println!("{}", b64_url);