Skip to main content

codec_base64/
decode.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5use base64::{engine::general_purpose::STANDARD, Engine as _};
6
7use crate::error::Base64Error;
8
9/// Decode standard padded Base64 from RFC 4648.
10pub fn base64_to_bytes(input: &str) -> Result<Vec<u8>, Base64Error> {
11    STANDARD
12        .decode(input.as_bytes())
13        .map_err(|_| Base64Error::Invalid)
14}