Generate hashes using various cryptographic algorithms: MD5, SHA-1, SHA-256, SHA-512, SHA-3, RIPEMD-160, and Keccak-256.
A hash function is a mathematical function that converts an input (or 'message') into a fixed-size string of bytes, typically a digest, that appears random. Hash functions are used for data integrity verification, password storage, digital signatures, and more. The ideal hash function has the following properties: it's deterministic (same input always gives same output), fast to compute, infeasible to generate a message from its hash, small changes to input result in a significantly different hash, and it's infeasible to find two different messages with the same hash.
The security of a hash function is determined by its resistance to: 1) Collision attacks (finding two different inputs with the same hash), 2) Preimage attacks (recovering the input from its hash value), and 3) Second-preimage attacks (finding another input with the same hash as a given input). Modern hash algorithms like SHA-256 and SHA-3 are designed to be resistant to these attacks. However, older algorithms like MD5 and SHA-1 have known vulnerabilities and shouldn't be used for security-critical applications.
MD5 produces a 128-bit (16-byte) hash value. It was designed by Ronald Rivest in 1991 to replace MD4.
Security: Critically broken - demonstrated collision attacks exist. Should not be used for any security purposes.
Use cases: Legacy systems only. Should not be used for new applications, even for file integrity checks.
SHA-1 produces a 160-bit (20-byte) hash value. It was designed by the NSA and published in 1995.
Security: Broken - practical collision attacks have been demonstrated since 2017. Not suitable for security applications.
Use cases: Should be avoided in all new applications. Many systems are actively removing SHA-1 support.
Part of the SHA-2 family, SHA-256 produces a 256-bit (32-byte) hash value. It was designed by the NSA and published in 2001.
Security: Strong - no practical attacks have been demonstrated against SHA-256. Widely trusted and used.
Use cases: Digital signatures, certificates, data integrity, Bitcoin, and other secure applications.
Part of the SHA-2 family, SHA-512 produces a 512-bit (64-byte) hash value. It was designed by the NSA and published in 2001.
Security: Strong - larger output size than SHA-256, but not necessarily more secure against most attack scenarios.
Use cases: Applications requiring longer hash output, but note that SHA-256 is sufficient for most security applications.
SHA-3 was selected by NIST in 2012 after a public competition. It's based on the Keccak algorithm and can produce various digest sizes.
Security: Very strong - designed with different internal structure than SHA-2 to provide protection against different types of attacks.
Use cases: Future-proofing cryptographic systems, applications requiring the highest security.
RIPEMD-160 produces a 160-bit (20-byte) hash value. It was developed in Europe by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.
Security: Moderate - stronger than MD5 and SHA-1, but less studied than SHA-2/SHA-3.
Use cases: Cryptocurrency addresses (Bitcoin uses RIPEMD-160 in combination with SHA-256).
Keccak-256 is a variant of the Keccak algorithm that produces a 256-bit hash. It's similar to SHA-3 but uses different padding rules.
Security: Very strong - the core algorithm for SHA-3, but with different parameterization.
Use cases: Ethereum blockchain for transaction hashing, smart contracts, and proof-of-work.