neco-base64 0.1.0

zero dependency Base64 encoder and decoder
Documentation
  • Coverage
  • 63.64%
    7 out of 11 items documented0 out of 0 items with examples
  • Size
  • Source code size: 15.87 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.69 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 51s Average build duration of successful builds.
  • all releases: 2m 51s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • barineco/neco-crates
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • barineco

neco-base64

Japanese

A zero-dependency Base64 encoder and decoder supporting standard and URL-safe alphabets.

Usage

use neco_base64::{encode, decode, encode_url, decode_url};

let encoded = encode(b"hello");       // "aGVsbG8="
let decoded = decode("aGVsbG8=").unwrap(); // b"hello"

let url_encoded = encode_url(b"hello");         // "aGVsbG8"
let url_decoded = decode_url("aGVsbG8").unwrap(); // b"hello"

API

Encode

Function Description
encode(input: &[u8]) -> String Standard Base64 with padding
encode_url(input: &[u8]) -> String URL-safe Base64, no padding
encode_url_padded(input: &[u8]) -> String URL-safe Base64 with padding

Decode

Function Description
decode(input: &str) -> Result<Vec<u8>, Base64Error> Standard Base64 (padding optional)
decode_url(input: &str) -> Result<Vec<u8>, Base64Error> URL-safe Base64 (padding optional)
decode_url_strict(input: &str) -> Result<Vec<u8>, Base64Error> URL-safe, rejects padding chars and non-zero trailing bits

Error

pub enum Base64Error {
    InvalidCharacter,
    InvalidLength,
    NonZeroPaddingBits,
}

License

MIT