#base62 #encode-decode #alphabet #zero #endian #leading #big

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

#1 in #leading

Download history 66/week @ 2024-11-01 156/week @ 2024-11-08 125/week @ 2024-11-15 9/week @ 2024-11-22 4/week @ 2024-11-29

360 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