base64.rs (844B)
1 // Copyright 2022 Adobe. All rights reserved. 2 // This file is licensed to you under the Apache License, 3 // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 4 // or the MIT license (http://opensource.org/licenses/MIT), 5 // at your option. 6 7 // Unless required by applicable law or agreed to in writing, 8 // this software is distributed on an "AS IS" BASIS, WITHOUT 9 // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or 10 // implied. See the LICENSE-MIT and LICENSE-APACHE files for the 11 // specific language governing permissions and limitations under 12 // each license. 13 14 use base64::{engine::general_purpose, Engine as _}; 15 16 pub(crate) fn encode(data: &[u8]) -> String { 17 general_purpose::STANDARD.encode(data) 18 } 19 20 pub(crate) fn decode(data: &str) -> Result<Vec<u8>, base64::DecodeError> { 21 general_purpose::STANDARD.decode(data) 22 }