Crates.io | uuid_base64 |
lib.rs | uuid_base64 |
version | 0.1.4 |
source | src |
created_at | 2024-10-30 14:35:46.522048 |
updated_at | 2024-11-21 01:54:12.339631 |
description | UUID shortener |
homepage | |
repository | |
max_upload_size | |
id | 1428609 |
size | 3,087 |
This library provides a simple function to convert a UUID to a Base64-encoded string. This can help shorten the UUID for display or storage purposes.
Make sure you have Rust installed. Then, create a new project or clone this repository and add the following dependencies to your Cargo.toml
file:
[dependencies]
uuid = { version = "1.0", features = ["v4"] }
base64 = "0.13"
Here's an example of how to use the uuid_to_base64 function:
extern crate uuid;
extern crate base64;
use uuid::Uuid;
use base64::encode;
pub fn uuid_to_base64(uuid: &Uuid) -> String {
encode(uuid.as_bytes())
}
#[cfg(test)]
mod tests {
use super::*;
use uuid::Uuid;
#[test]
fn test_uuid_to_base64() {
let uuid = Uuid::new_v4();
let encoded = uuid_to_base64(&uuid);
println!("UUID: {}", uuid);
println!("Base64: {}", encoded);
// Add assertions as needed
}
}
cargo test
This project is licensed under the MIT License.
bensatlantik