SHA-3 ExampleSHA-3 was known as Keccak and is a hash function designed by Guido Bertoni, Joan Daemen, Michaƫl Peeters, and Gilles Van Assche. MD5 and SHA-0 have been shown to be susceptible to attacks, along with theoretical attacks on SHA-1. NIST thus defined there was a need for a new hashing method which did not use the existing methods for hashing, and setup a competition for competing algorithms. In October 2012, Keccak won the NIST hash function competition, and is proposed as the SHA-3 standard. It should be noted that it is not replacement SHA-2, which is currently a secure methods. Overall Keccak uses the sponge construction where the message blocks are XORed into the initial bits of the state, and then invertibly permuted. [Theory] The results are then:
|
Examples
- Try "The quick brown fox jumps over the lazy dog". Try!, which should give a SHA-3 (256) hash of: 4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15 Check or Check
- Try "". Try!, which should give a SHA-3 (256) hash of: c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 Check or Check
- Try "abc". Try!, which should give a SHA-3 (256) hash of: 4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 Check
- Try "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq". Try!, which should give a SHA-3 (256) hash of: 45d3b367a6904e6e8d502ee04999a7c27647f91fa845d456525fd352ae3d7371 Check
Presentation
Sample code
After much experimenting, this is the code that implements SHA-3 properly. It was created by Joe Dluzen et al:
uses SHA3; // Uses the DLL from http://nuget.org/packages/SHA3/ // Authors: Joe Dluzen, Bertoni Daemen Peeters and Van Assche public void checkSHA3(string message) { if (message == null) return; byte[] bytes = null; byte[] r = null; SHA3.SHA3Unmanaged hash = null; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); hash = new SHA3Unmanaged(224); bytes = encoding.GetBytes(message); r = hash.ComputeHash(bytes); hash1 = Global.ByteToString(r); hash = new SHA3Unmanaged(256); bytes = encoding.GetBytes(message); r = hash.ComputeHash(bytes); hash2 = Global.ByteToString(r); hash = new SHA3Unmanaged(384); bytes = encoding.GetBytes(message); r = hash.ComputeHash(bytes); hash3 = Global.ByteToString(r); hash = new SHA3Unmanaged(512); bytes = encoding.GetBytes(message); r = hash.ComputeHash(bytes); hash4 = Global.ByteToString(r); }