uuid_base64

Crates.iouuid_base64
lib.rsuuid_base64
version0.1.4
sourcesrc
created_at2024-10-30 14:35:46.522048
updated_at2024-11-21 01:54:12.339631
descriptionUUID shortener
homepage
repository
max_upload_size
id1428609
size3,087
Ben Santora (bensatlantik)

documentation

README

uuid_base64

UUID Base64 Converter

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.

Installation

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"

Usage

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
    }
}

Testing

cargo test

License

This project is licensed under the MIT License.

Author

bensatlantik

Commit count: 0

cargo fmt