Do You Know Your Keccak From Your SHA-3, And Your SHAKE From Your KMAC
NIST choose Keccak as the standard for SHA-3. But, it’s all a bit confusing, as there are two main versions of this: Keccak and SHA-3. Many systems, such as Ethereum have adopted Keccak, while others go for SHA-3.
Keccak or SHA-3?
In 2006, NIST initiated the SHA-3 project, and the winner was announced in 2012. Basically, the only difference between SHA-3 and Keccak, is that NIST changed the padding of the data, and where the two hashing methods have the same security level. But, many still question why NIST did this. Some Node.js code for this is:
sha3_512 = require('js-sha3').sha3_512;
sha3_384 = require('js-sha3').sha3_384;
sha3_256 = require('js-sha3').sha3_256;
sha3_224 = require('js-sha3').sha3_224;
keccak512 = require('js-sha3').keccak512;
keccak384 = require('js-sha3').keccak384;
keccak256 = require('js-sha3').keccak256;
keccak224 = require('js-sha3').keccak224;console.log("SHA-3 224: ",sha3_224(msg));
console.log("SHA-3 256: ",sha3_256(msg));
console.log("SHA-3 384: ",sha3_384(msg));
console.log("SHA-3 512: ",sha3_512(msg));console.log("\nKeccak224: ",keccak224(msg));
console.log("Keccak256: ",keccak256(msg));
console.log("Keccak384: ",keccak384(msg));
console.log("Keccak512: ",keccak512(msg));