1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! # Cryptographic Hash Functions Module
//!
//! This module provides implementations of various cryptographic hash functions,
//! ranging from legacy algorithms to modern secure hash functions.
//!
//! ## Available Hash Functions
//!
//! - **MD5**: 128-bit hash function (⚠️ **Deprecated** - cryptographically broken)
//! - **SHA-1**: 160-bit hash function (⚠️ **Deprecated** - collision vulnerabilities)
//! - **SHA-256**: 256-bit hash function (✅ **Secure** - recommended for modern use)
//!
//! ## Security Considerations
//!
//! ### Secure for Production
//! - **SHA-256**: Part of the SHA-2 family, cryptographically secure and widely adopted
//!
//! ### Deprecated/Insecure
//! - **MD5**: Vulnerable to collision attacks, should only be used for checksums
//! - **SHA-1**: Deprecated due to collision vulnerabilities, avoid for security purposes
//!
//! ## Usage Examples
//!
//! ```rust
//! use ruscrypt::hash::{md5, sha1, sha256};
//!
//! // Modern secure hashing (recommended)
//! let secure_hash = sha256::hash("sensitive data").unwrap();
//! println!("SHA-256: {}", secure_hash);
//!
//! // Legacy hashing (for compatibility only)
//! let legacy_hash = md5::hash("legacy data").unwrap();
//! println!("MD5: {}", legacy_hash);
//! ```
//!
//! ## Output Formats
//!
//! All hash functions return hexadecimal strings:
//! - MD5: 32 hexadecimal characters (128 bits)
//! - SHA-1: 40 hexadecimal characters (160 bits)
//! - SHA-256: 64 hexadecimal characters (256 bits)
//!
//! ## Performance
//!
//! These implementations prioritize educational clarity over performance.
//! For production applications requiring high-performance hashing, consider
//! using optimized libraries like `ring` or `sha2`.
/// MD5 hash function implementation
///
/// ⚠️ **Security Warning**: MD5 is cryptographically broken and should not be used
/// for security purposes. Included for educational and legacy compatibility only.
/// SHA-1 hash function implementation
///
/// ⚠️ **Deprecated**: SHA-1 has known collision vulnerabilities and should not be
/// used for new applications. Use SHA-256 instead.
/// SHA-256 hash function implementation
///
/// ✅ **Secure**: SHA-256 is cryptographically secure and recommended for modern
/// applications requiring hash functions.