Crate mdg

Source
Expand description

§A Rust library that implements the MD5 cryptographic hash function

Rust

Rust Crates.io Lib.rs GitHub License

§Overview

The Message Digest (MDG) is an easy way to produces a 128-bit (16-byte) hash value using the MD5 cryptographic hash function. It provides a struct, MD5, that can generate a message digest of data in a secure, one-way hash. The message digest can verify the integrity of the data without having to store the entire message.

Several options are available to produce the hash value:

  • MD5::default() - Returns the hash value of an empty string.
  • MD5::digest() - Returns the hash value of a string.
  • MD5::finalize() - Finalize the MD5 object and return the result as a 16-byte array.
  • MD5::hexdigest() - Returns the hash value of a string as a hexadecimal string.
  • MD5::new() - Create a new instance of the MD5 struct.
  • MD5::reset() - Reset the internal state of the MD5 object.
  • MD5::to_hex_string() - Returns the hash value of a string as a hexadecimal string.
  • MD5::to_string() - Returns the hash value of a string as a string.
  • MD5::update() - Update the internal state of the MD5 object with new data.
  • MD5::update_file() - Update the internal state of the MD5 object with new data from a file.

To use this crate, add mdg to your Cargo.toml:

[dependencies]
mdg = "0.0.1"

§Usage

  • serde: Enable serialization/deserialization via serde

§Examples

use mdg::MD5;

let hash = MD5::default();
assert_eq!(hash.to_string(), "d41d8cd98f00b204e9800998ecf8427e");

§Warning

This crate is not intended for cryptographic use. MD5 is not a cryptographically secure hashing algorithm and should not be used for applications that require a collision-resistant hash function.

MD5 is sensitive to length extension attacks, which alter the hash value if additional data is appended to the input.

Re-exports§

pub use constants::*;
pub use digest::*;

Modules§

constants
Import the constants module.
digest
Import the digest module.

Structs§

MD5
The MD5 struct.
MD5Params
MD5Params

Functions§

f
Rotate left
g
Rotate left
h
Rotate left
i
Rotate left
mdg_f
mdg_f
mdg_h
mdg_h
mdg_i
mdg_i
rotate_left
Rotate left