Module vendor_base64::base64
source · Expand description
Base64 encoding and decoding
Examples
use vendor_base64::base64; // Replace vendor_base64 with your project name
// Encode
let bytes = "rust".as_bytes();
let encoded = base64::encode(bytes);
assert_eq!(encoded, "cnVzdA==");
// Decode
let decoded = base64::decode(&encoded).unwrap();
assert_eq!(decoded, bytes);
// Decode without padding
let decoded = base64::decode("cnVzdA").unwrap();
assert_eq!(decoded, bytes);Structs
- Error that can occur when calling
decode()if the string is not valid base64
Functions
- Decode base64 string to bytes. Handles padding and no padding.
- Encode bytes to base64 string.