Function from_base64

Source
pub fn from_base64(encoded: &str) -> Result<Vec<u8>>
Expand description

Decodes a Base64 string to binary data.

Accepts standard Base64 format with optional padding.

§Arguments

  • encoded - The Base64-encoded string

§Returns

Returns the decoded binary data.

§Errors

Returns an error if the input is not valid Base64.

§Examples

use ruscrypt::utils::{to_base64, from_base64};
 
let original = b"Hello, World!";
let encoded = to_base64(original);
let decoded = from_base64(&encoded).unwrap();
assert_eq!(original, &decoded[..]);