Hash Example (Hex)MD5, SHA-1 and SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512) produce a hash signature, and the output is typically shown in a hex format or a Base-64. In this example the output is converted into a Hex format. MD5 and SHA-0 have been shown to have collision, and are prone to attacks. Along with this SHA-1 has been shown to be prone to the theoretical attack. SHA-2 is not susceptible to these attacks. The results are then:
|
Examples
- Try "The quick brown fox jumps over the lazy dog.". Try!, which should give a SHA-1 of: 408d94384216f890ff7a0c3528e8bed1e0b01621
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a SHA-1 of: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
- Try "a" . Try!, which should give a MD5 of: 0cc175b9c0f1b6a831c399e269772661
- Try "abc". Try!, which should give a MD5 of: 900150983cd24fb0d6963f7d28e17f72
- Try "message digest". Try!, which should give a MD5 of: f96b697d7cb7938d525a2f31aaf161d0
- Try "abcdefghijklmnopqrstuvwxyz". Try!, which should give a MD5 of: c3fcd3d76192e4007dfb496cca67e13b
- Try "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789". Try!, which should give a MD5 of: d174ab98d277d9f5a5611c2c9f419d9f
- Try "12345678901234567890123456789012345678901234567890123456789012345678901234567890". Try!, which should give a MD5 of: 57edf4a22be3c955ac49da2e2107b67a
Collision
A collision occurs when there are two different values that produce the same hash signature. In the following example we use a hex string to define the data element (as the characters would be non-printing). For the following we have different values which create the same hash signature (the red characters identify the changes in the input data):
d131dd02c5e6eec4693d9a0698aff95c 2fcab58712467eab4004583eb8fb7f89 55ad340609f4b30283e488832571415a 085125e8f7cdc99fd91dbdf280373c5b d8823e3156348f5bae6dacd436c919c6 dd53e2b487da03fd02396306d248cda0 e99f33420f577ee8ce54b67080a80d1e c69821bcb6a8839396f9652b6ff72a70Try!, which should give a MD4 hash of: 79054025255FB1A26E4BC422AEF54EB4 Check
d131dd02c5e6eec4693d9a0698aff95c 2fcab50712467eab4004583eb8fb7f89 55ad340609f4b30283e4888325f1415a 085125e8f7cdc99fd91dbd7280373c5b d8823e3156348f5bae6dacd436c919c6 dd53e23487da03fd02396306d248cda0 e99f33420f577ee8ce54b67080280d1e c69821bcb6a8839396f965ab6ff72a70Try!, which should give a MD4 hash of: 79054025255FB1A26E4BC422AEF54EB4 Check
Presentation
Sample Code
using System.Security.Cryptography; using System.Security.Principal; public void checkMD5(string message) { if (message == null) return; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); MD5 md5 = new MD5CryptoServiceProvider(); SHA1 sha1 = new SHA1CryptoServiceProvider(); SHA256Managed sha256 = new SHA256Managed(); SHA384Managed sha384 = new SHA384Managed(); SHA512Managed sha512 = new SHA512Managed(); byte[] messageBytes = encoding.GetBytes(message); byte[] hashmessage = md5.ComputeHash(messageBytes); hash1 = Global.ByteToString(hashmessage); hashmessage = sha1.ComputeHash(messageBytes); hash2 = Global.ByteToString(hashmessage); hashmessage = sha256.ComputeHash(messageBytes); hash3 = Global.ByteToString(hashmessage); hashmessage = sha384.ComputeHash(messageBytes); hash4 = Global.ByteToString(hashmessage); hashmessage = sha512.ComputeHash(messageBytes); hash5 = Global.ByteToString(hashmessage); }