#base62 #zero #encode-decode #leading #standard #en #wikipedia

rust-base62

A simple library base62 encode/decode, no dependencies other libraries

3 unstable releases

0.2.0 Nov 15, 2024
0.1.1 Nov 8, 2024
0.1.0 Nov 7, 2024

#3 in #leading

Download history 122/week @ 2024-11-14 14/week @ 2024-11-21 3/week @ 2024-11-28 3/week @ 2024-12-05 3/week @ 2024-12-12

105 downloads per month

GPL-3.0-only

16KB
203 lines

rust-base62

A simple library base62 encode/decode, no dependencies other libraries.

Use big endian and support leading zeros.

Alphabet

It supports the standard [0-9A-Za-z] : https://en.wikipedia.org/wiki/Base62

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Example

use rust_base62;
fn main() {
    let plaintext = "hello";
    let ciphertext = rust_base62::encode(plaintext.as_bytes());
    let decode = rust_base62::decode(ciphertext.as_bytes()).unwrap();
    println!("cipher text: {}", ciphertext);
    println!("decode text: {}", String::from_utf8(decode).unwrap())
}

lib.rs:

A simple library base62 encode/decode, no dependencies other libraries.

No runtime deps