Open In App

Difference Between SHA-256 and Keccak-256

The best way to think of SHA-256 is as a group of cryptographic hash functions. A hash function, also known as a digest or fingerprint, functions as a special signature for a text or data file. Due to the fact that it only supports one-way cryptographic operations, it cannot be read or decrypted. This makes it possible to employ hashing for applications such as the validation of files, digital signatures, secure messages, and others.

How does SHA-256 work?



Does SHA-256 remain in use?

Keccak-256

Keccak-256, a cryptographic function, is part of Solidity (SHA-3 Family). This function computes the hash of an input to a fixed-length output, yielding a singular 32-byte hash from any number of inputs. This cryptographic hash function can only be used in one direction and cannot be reversed.



How Does Keccak-256 Work?

Give a string as input, such as “Namaste Duniya,” then send it through a hash function using keccak256. This would lead to:

Namaste Duniya -> keccak-256(hashing function) -> 8a0fe4fd16bb35fbecde2e774008fb7f92a8568a680f3fa93d0948bcfbf68dc3

The string “Namaste Duniya”, is not the same as “namaste duniya”. If we hash “namaste duniya”, we will get a totally different result.

namaste duniya -> keccak-256(hashing function) -> 544ff8f09d34fdfbfa5a8dcb9d7d57deb6c862026cb8b655cfd7bf9c192e4d21

Even the slightest alteration or modification to the string has a significant impact on the hash digest. No matter how much input is provided, the outcome will always be the same.

What are the Use Cases of Keccak-256?

These are some use cases for it:

SHA-256 vs Keccak-256

Below are some of the differences between SHA-256 and Keccak-256.

S No. SHA-256 Keccak-256
1. SHA-256 is the implementation of the SHA-2 standard with a 256 bits key. Keccak256, a cryptographic function, is part of Solidity (SHA-3 Family).
2. The SHA-256 is weaker than Keccak-256. The keccak-256 is much stronger compared to SHA-256.
3. Computes the SHA-256 hash of the input. Computes the Keccak-256 hash of the input.
4. sha256(bytes memory) returns (bytes32). keccak256(bytes memory) returns (bytes32).
5. The Bitcoin blockchain makes extensive use of SHA-256, including when identifying transaction hashes and when miners are performing proof-of-work mining. Ethereum uses Keccak-256 in a consensus engine called Ethash. 
Article Tags :