From 658224d8567d5131dcee2d1b125f02a66d5513c6 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Sat, 29 Feb 2020 19:31:29 +0100 Subject: [PATCH] [doc] create summary + add sha256 example --- src/dewif.rs | 16 +++++++++++++--- src/hashs/mod.rs | 18 ++++++++++++++++++ src/keys/mod.rs | 2 +- src/lib.rs | 10 ++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/dewif.rs b/src/dewif.rs index e7a8c89..ce0147d 100644 --- a/src/dewif.rs +++ b/src/dewif.rs @@ -13,9 +13,19 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -//! Handle [DEWIF](https://git.duniter.org/nodes/common/doc/blob/dewif/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md) format +//! Handle [DEWIF][dewif-spec] format //! -//! # Write ed25519 key-pair in DEWIF file +//! See [DEWIF format specifications][dewif-spec]. +//! +//! [dewif-spec]: https://git.duniter.org/documents/rfcs/blob/dewif/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md +//! +//! # Summary +//! +//! * [Write DEWIF file](#write-ed25519-key-pair-in-dewif-file) +//! * [Read DEWIF file](#read-dewif-file) +//! +//! +//! ## Write ed25519 key-pair in DEWIF file //! //! ``` //! use dup_crypto::dewif::{Currency, G1_TEST_CURRENCY, write_dewif_v1_content}; @@ -40,7 +50,7 @@ //! ) //! ``` //! -//! # Read DEWIF file +//! ## Read DEWIF file //! //! ``` //! use dup_crypto::dewif::{Currency, ExpectedCurrency, read_dewif_file_content}; diff --git a/src/hashs/mod.rs b/src/hashs/mod.rs index a89af43..c94cd7d 100644 --- a/src/hashs/mod.rs +++ b/src/hashs/mod.rs @@ -14,6 +14,24 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. //! Provide wrappers for cryptographic hashs +//! +//! # Summary +//! +//! * [Compute Sha256 hash](#compute-sha256-hash) +//! +//! ## Compute sha256 hash +//! +//! ``` +//! use dup_crypto::hashs::Hash; +//! +//! let hash: Hash = Hash::compute(b"datas"); +//! +//! assert_eq!( +//! "958D41C80EF75834EFFC9CBE2E8AEE11AEDE28ADA596E876B8261EDF53266B40", +//! &hash.to_hex(), +//! ); +//! ``` +//! use crate::bases::*; #[cfg(feature = "rand")] diff --git a/src/keys/mod.rs b/src/keys/mod.rs index ebb663a..ad9463c 100644 --- a/src/keys/mod.rs +++ b/src/keys/mod.rs @@ -18,7 +18,7 @@ //! - Keys can be converted to/from Base58 string format. //! - Signatures can be converted to/from Base64 string format. //! -//! # Usage +//! # Generate and use ed25519 key-pair //! //! ``` //! use dup_crypto::keys::{KeyPair, PublicKey, Signator, Signature}; diff --git a/src/lib.rs b/src/lib.rs index 0eeb19e..c1f0f3b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,16 @@ //! //! `dup` means DUniter Protocols. //! +//! ## Summary +//! +//! * [Handle DEWIF format](./dewif/index.html#handle-dewif-format) +//! * [Write DEWIF file](./dewif/index.html#write-ed25519-key-pair-in-dewif-file) +//! * [Read DEWIF file](./dewif/index.html#read-dewif-file) +//! * [Sha256](./hashs/index.html) +//! * [Compute Sha256 hash](./hashs/index.html#compute-sha256-hash) +//! * [Ed25519](./keys/index.html) +//! * [generate and use ed25519 key-pair](./keys/index.html#generate-and-use-ed25519-key-pair) +//! #![deny( clippy::option_unwrap_used, -- GitLab