# Hashing Algorithms: MD5, SHA-256 ## MD5 MD5 (Message Digest Algorithm 5) is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. It is commonly used to verify data integrity. MD5 is considered to be a weak hash function as it has known vulnerabilities. ```python import hashlib def md5_hash(input_string): return hashlib.md5(input_string.encode()).hexdigest() print(md5_hash("Hello, World!")) # Outputs: '65a8e27d8879283831b664bd8b7f0ad4' ``` This function will hash the string "Hello, World!" and output the MD5 hash. ## SHA-256 SHA-256 (Secure Hash Algorithm 256 bit) is part of the SHA-2 family. It is a stronger hash function compared to MD5, providing a greater level of security. It generates an almost-unique 256-bit (32-byte) signature for a text. ```python def sha256_hash(input_string): return hashlib.sha256(input_string.encode()).hexdigest() print(sha256_hash("Hello, World!")) # Outputs: '315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3' ``` This function will hash the string "Hello, World!" and output the SHA-256 hash. Keep in mind, while SHA-256 is more secure than MD5, no hash function is impervious. The security of a hash function largely depends on its ability to produce unique hashes; if two different inputs produce the same hash (a collision), it opens the potential for nefarious activity. For this reason, developing and maintaining robust, secure hashing algorithms is a dynamic and ongoing field of study in cryptography.