| Crates.io | conv64 |
| lib.rs | conv64 |
| version | 0.1.0 |
| created_at | 2023-11-11 13:08:18.052131+00 |
| updated_at | 2023-11-11 13:08:18.052131+00 |
| description | A simple base 10 to base 64 converter |
| homepage | |
| repository | https://github.com/Brian3647/conv64 |
| max_upload_size | |
| id | 1032033 |
| size | 6,295 |
Easily (& blazingly fast) convert base 10 numbers to base 64.
IMPORTANT NOTE: This is base 64 as in the number base, if you're searching for base64 encryption, use this
# Cargo.toml
[dependencies]
conv64 = "*"
// main.rs
fn main() {
let x = conv64::encode(1234567890);
println!("{}", x); // 19bWBI
// With the `rand` feature enabled:
let y = conv64::generate(1..2000);
println!("{}", y); // A random number between 1 and 2000, encoded in base 64
// Get the maximum value a base 64 number can have with a given number of letters
assert_eq!(conv64::max_value_for_letters(1), Some(63));
}
The main application for this is using it as an ID generator/shortener (for example, YouTube video IDs are base 64 encoded numbers).
Since its main use is for the web, the 2 extra characters (+ and /) are replaced with - and _ respectively, so it can be used in URLs without encoding.
This project is licensed under the MIT License.