Crates.io | tablesalt |
lib.rs | tablesalt |
version | 0.3.1 |
source | src |
created_at | 2023-05-25 10:18:03.975088 |
updated_at | 2023-06-17 00:49:34.94054 |
description | A safe, oxidized wrapper for libsodium |
homepage | https://github.com/JacoMalan1/tablesalt |
repository | https://github.com/JacoMalan1/tablesalt |
max_upload_size | |
id | 874194 |
size | 35,209 |
TableSalt is a safe, oxidized wrapper for libsodium.
To use tablesalt, add start by adding it as a dependency in your Cargo.toml
file.
[dependencies]
tablesalt = "0.3.1"
Currently, TableSalt only provides libsodium's crypto_generichash API.
The following example shows how to hash a simple message. The code here uses the crate
hex
to encode the hash, which is a Vec<u8>
into a hexadecimal string.
use tablesalt::sodium;
fn main() {
let s = sodium::Sodium::new();
let hash = s.crypto_generichash(b"Some message", None, 32);
println!("blake2b hash: {}", hex::encode(&hash));
}
use tablesalt::sodium;
fn main() {
let s = sodium::Sodium::new();
let mut state = s.crypto_generichash_init(None, 32);
state.update(b"Some ");
state.update(b"message");
let hash = state.finalize();
println!("blake2b hash: {}", hex::encode(&hash));
}