Crates.io | exonum-crypto |
lib.rs | exonum-crypto |
version | 1.0.0 |
source | src |
created_at | 2018-12-14 10:13:30.514763 |
updated_at | 2020-03-31 15:41:01.879901 |
description | Cryptography related types, constants, traits and functions. |
homepage | https://exonum.com/ |
repository | https://github.com/exonum/exonum |
max_upload_size | |
id | 101873 |
size | 63,332 |
exonum-crypto
provides a high-level API for work with various cryptography tasks.
Capabilities of exonum-crypto
include:
The main backend for exonum-crypto
is sodiumoxide
, and the used algorithms are:
Consult the crate docs for more details.
Signing data and verifying the signature:
exonum_crypto::init();
let (public_key, secret_key) = exonum_crypto::gen_keypair();
let data = [1, 2, 3];
let signature = exonum_crypto::sign(&data, &secret_key);
assert!(exonum_crypto::verify(&signature, &data, &public_key));
Hashing fixed amount of data:
exonum_crypto::init();
let data = [1, 2, 3];
let hash = exonum_crypto::hash(&data);
Hashing data by chunks:
use exonum_crypto::HashStream;
exonum_crypto::init();
let data: Vec<[u8; 5]> = vec![[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]];
let mut hash_stream = HashStream::new();
for chunk in data {
hash_stream = hash_stream.update(&chunk);
}
let _ = hash_stream.hash();
Include exonum-crypto
as a dependency in your Cargo.toml
:
[dependencies]
exonum-crypto = "1.0.0"
exonum-crypto
is licensed under the Apache License (Version 2.0).
See LICENSE for details.