base64_light

Base64 Encoder & Decoder

6 releases

0.1.5 Feb 20, 2023
0.1.4 Feb 20, 2023

#715 in Encoding

Download history 476/week @ 2024-07-22 289/week @ 2024-07-29 284/week @ 2024-08-05 227/week @ 2024-08-12 319/week @ 2024-08-19 181/week @ 2024-08-26 190/week @ 2024-09-02 219/week @ 2024-09-09 108/week @ 2024-09-16 375/week @ 2024-09-23 336/week @ 2024-09-30 204/week @ 2024-10-07 147/week @ 2024-10-14 184/week @ 2024-10-21 262/week @ 2024-10-28 145/week @ 2024-11-04

743 downloads per month
Used in 4 crates

CC0 license

13KB
175 lines

base64_light

Base64 Encoder, Decoder for Rust. This is very simple Base64 library.

How to use

Add 'base64_light' to your project's Cargo.toml.

[package]
...
[dependencies]
base64_light = "0.1"

And use 'base64_encode()' or 'base64_decode_str()' etc ...

use base64_light::*;
fn main() {
    let s = "hello!";
    println!("{} => {}", s, base64_encode(s)); // hello! => aGVsbG8h
    let b = "aGVsbG8h";
    println!("{} <= {}", b, base64_decode_str(b)); // aGVsbG8h <= hello!
}

Methods

Encode

  • base64_encode(in_str: &str) -> String
  • base64_encode_bytes(in_bytes: &[u8]) -> String
  • base64url_encode(in_str: &str) -> String
  • base64url_encode_bytes(bytes: &[u8]) -> String
  • base64_encode_splitlines(in_str: &str) -> String
  • base64_encode_splitlines_bytes(in_bytes: &[u8])

Decode

  • pub fn base64_decode(b64str: &str) -> Vec<u8>
  • pub fn base64_decode_str(b64str: &str) -> String

No runtime deps