Skip to content

JacoMalan1/tablesalt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TableSalt

codecov test safety schedule check

Description

TableSalt is a safe, oxidized wrapper for libsodium.

Usage

To use tablesalt, add start by adding it as a dependency in your Cargo.toml file.

[dependencies]
tablesalt = "0.3.1"

Hashing

Currently, TableSalt only provides libsodium's crypto_generichash API.

Hashing a message

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

Hashing a multi-part message

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

About

A safe, oxidized wrapper for libsodium.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages