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

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 192/week @ 2024-11-03 121/week @ 2024-11-10 31/week @ 2024-11-17

344 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