#sha-1 #hash #id #generate #double-click #double-clickable

okid

A library for generating double clickable ids

33 releases (10 breaking)

new 0.11.1 Feb 19, 2025
0.10.1 Feb 16, 2025
0.5.3 Nov 21, 2024

#244 in Cryptography

Download history 1/week @ 2024-10-30 761/week @ 2024-11-06 58/week @ 2024-11-13 703/week @ 2024-11-20 67/week @ 2024-11-27 449/week @ 2024-12-04 246/week @ 2024-12-11 71/week @ 2024-12-18 48/week @ 2024-12-25 84/week @ 2025-01-01 84/week @ 2025-01-08 173/week @ 2025-01-15 48/week @ 2025-01-22 248/week @ 2025-01-29 24/week @ 2025-02-05 686/week @ 2025-02-12

1,069 downloads per month

BSD-3-Clause

755KB
1.5K SLoC

okid

FOSSA Status

okid is a library for generating double clickable representations of various types of data, such as sha1 hashes, uuids and more.

sha1

#[cfg(feature = "sha1")]
{
    use sha1::Digest as sha1digest;
    let hasher = sha1::Sha1::new();
    let binary_id = okid::OkId::from(hasher);
}

sha256

#[cfg(feature = "sha2")]
{
    use sha2::Digest;
    let mut hasher = sha2::Sha256::new();
    hasher.update(b"hello world");
    let binary_id = okid::OkId::from(hasher);
}

The resulting strings look like this: 2ː00b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 first character of the string is the type of the binary data in this case 2 means sha256 the rest of the string is the hexadecimal representation of the binary data

okid macro

The okid! macro can be used to parse OkIds from string literals at compile time.

use okid::{okid, OkId};
#[cfg(feature = "sha2")]
const HELLO_WORLD_SHA256: OkId = okid!("2ːb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");

License

FOSSA Status

Dependencies

~6–21MB
~302K SLoC