shuttle_core/crypto/
mod.rs1use sodiumoxide;
3use sodiumoxide::randombytes;
4use sodiumoxide::crypto::hash::sha256;
5
6mod keypair;
7mod strkey;
8mod ecdh;
9mod sha;
10
11pub use self::keypair::{KeyPair, PublicKey, SecretKey};
12pub use self::ecdh::{Curve25519Public, Curve25519Secret};
13pub use self::sha::{HmacSha256Key, HmacSha256Mac};
14
15pub fn hash(m: &[u8]) -> Vec<u8> {
17 let digest = sha256::hash(&m);
18 digest.0.to_vec()
19}
20
21pub fn random_bytes(size: usize) -> Vec<u8> {
23 randombytes::randombytes(size)
24}
25
26pub fn init() -> bool {
31 sodiumoxide::init()
32}