| Crates.io | randid |
| lib.rs | randid |
| version | 0.1.0 |
| created_at | 2020-05-20 02:37:43.81391+00 |
| updated_at | 2020-05-20 02:37:43.81391+00 |
| description | Randid (pronounced like random but with `-id` instead of `-om`) is a minimalistic, web-safe library for generating customisable IDs for use in primarily web applications. |
| homepage | |
| repository | https://gitlab.com/owez/randid |
| max_upload_size | |
| id | 243660 |
| size | 6,822 |
Randid (pronounced like random but with -id instead of -om) is a minimalistic, web-safe library for generating customisable IDs for use in primarily web applications. The generated IDs are not guarenteed to be unique however!
Currently, this library has 2 main functions: randid_str() and randid_i32(). The former generates a random BASE62 (web-safe) string of a specified length and the latter creates a padded random integer of the specified length (like 00012 for a length of 5).
A random BASE62 string embedded as a url:
use randid::randid_str;
fn main() {
let my_id = randid_str(5);
println!("https://example.com/safeid/{}", my_id); // will provide a url-safe id like `bWk9D`, `yWvm3` or `POf3R`
}
Two padded random integers of 12 and 24 characters long respectively:
use randid::randid_i32;
fn main() {
let padded_num_12 = randid_i32(12);
let padded_num_24 = randid_i32(24);
println!(
"Guarenteed length of 12: {}, Guarenteed length of 24: {}",
padded_num_12,
padded_num_24
);
}