Open In App

Difference Between SHA-256 and Keccak-256

Last Updated : 22 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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?

  • In order to use SHA-256, a file or text must first be converted into binary, after which initial hash values and round constants must be set, a message schedule must be created, final values must be compressed, and finally, a string concatenation must be finished in order to combine all the bits.
  • One of the safest and most often used hash algorithms is SHA-256. It can be used to scramble and alter data irreversibly, which ensures that the input cannot be deduced from the SHA-256 algorithm’s output, which is 256 bits long.

Does SHA-256 remain in use?

  • Today’s uses for SHA-256 continue to be useful and include blockchain, cryptocurrencies, Secure Sockets Layer (SSL) certificates, and more.
  • SHA-256 is used in blockchain and cryptocurrency applications for mining, proof of work, and creating cryptocurrency addresses. The miner must go through a process in order to generate hash values for newly produced blocks, and that process includes SHA-256. Similar to that, the public key necessary to generate new Bitcoin addresses must conform to SHA-256.
  • A sort of security technology called an SSL certificate is used to create an encrypted connection between a client and a server. Websites and web services can communicate securely thanks to it. Certain cryptographic components of the SSL certification make use of SHA-256, the current industry standard.

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:

  • Ethereum uses Keccak-256 in a consensus engine called Ethash.
  • Small-sized cryptographic signature (by signing the hash instead of a larger input).
  • To extract a deterministic, unique ID from a collection of data.

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. 

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads