Difference Between SHA-256 and Keccak-256 - GeeksforGeeks (2024)

Last Updated : 22 Jul, 2022

Improve

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-256Keccak-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

Please Login to comment...

Difference Between SHA-256 and Keccak-256 - GeeksforGeeks (2024)

FAQs

What is the difference between SHA-256 and Keccak256? ›

Keccak-256 vs.

They are both used as a hashing algorithm, although they differ from each other. Let's take a look at the main differences between Keccak-256 and SHA-256. SHA-256 stems from the SHA-2 standard with a 256 bit key, while Keccak-256 is a function within Solidity and stems from the SHA-3 family.

What is the difference between SHA-256 and Keccak256 solidity? ›

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.

What is Keccak256 used for? ›

Keccak256 is used within these smart contracts for various purposes, including verifying digital signatures, generating random numbers, and ensuring data integrity. Mining and consensus: Keccak256 is employed in Ethereum's previous Proof of Work (PoW) mining algorithm, called Ethash.

What is the difference between SHA-256 and SHA-3-256? ›

How does SHA-3 differ from SHA-256? The SHA-256 is based on the Merkle-Damgård construction but the SHA-3 uses the sponge construction, this helps in order to provide resistance against certain types of cryptanalytic attacks.

What is the difference between SHA-2 and Keccak? ›

Keccak: The Secure but Resource-Hungry Contender

One of the primary difference from SHA2 lies in the round function. BLAKE involves 8 round functions (G0,…,G7) and 10 rounds. Keccak requires 24 rounds, with W=64 and L=6, resulting in nr=24 rounds. Each round includes θ(theta), ρ(rho), π(pi), χ(chi), and ι(iota) steps.

What is the difference between SHA-3 and keccak256? ›

Keccak-256 is the hashing algorithm used for signing Ethereum transactions. It is similar to the standardized SHA-3 but uses a different padding. Hence, it makes sense to include both variations, although the official SHA-3 is not used in Ethereum.

Which SHA hash is strongest? ›

Among MD4, MD5, SHA1, and SHA256, SHA256 is considered the strongest hash function in terms of security and cryptographic strength. It provides a higher level of security compared to MD4, MD5, and SHA1, making it more resistant to potential attacks. It's like having a super tough lock on your digital vault!

What is Keccak in solidity? ›

Keccak256 is a cryptographic hash function used in Solidity, the programming language for Ethereum smart contracts. It is based on the SHA-3 algorithm and provides an important security feature by ensuring data integrity and authenticity.

What is more secure than SHA-256? ›

SHA-512 Encryption

SHA-512, another variant of SHA-2, generates a hash digest of 512 bits. It's considered to be even more secure and complex than SHA-256 but at the expense of speed.

Is keccak256 deterministic? ›

keccak256 computes the Keccak-256 hash of the input. Some use cases are: Creating a deterministic unique ID from a input.

Is Keccak secure? ›

The sponge and duplex constructions used by Keccak are provably secure against generic attacks.

Does Ethereum use Keccak? ›

Ethereum uses KECCAK-256. It should be noted that it does not follow the FIPS-202 based standard (a.k.a SHA-3), which was finalized in August 2015. According to this, NIST changed the padding to SHA3-256(M) = KECCAK [512] (M || 01, 256).

Is SHA-256 outdated? ›

"SHA-2" is the traditional codename for a family of six functions that includes SHA-256 and SHA-512. These functions are considered completely fine and current and non-obsolete.

What are the cons of SHA-256? ›

SHA256 is not a perfect solution and has some drawbacks, such as being slower and more computationally intensive than MD5 and SHA-1, which can affect the performance and efficiency of applications or systems.

Is SHA-256 unbreakable? ›

Because SHA-256 is a one-way cryptographic algorithm, it's impossible to reverse-engineer the input from the output hash. This means that miners can't cheat the system by submitting a fake solution since other nodes on the network can easily verify the answer by checking the hash.

What is better than SHA-256? ›

SHA-512 offers better security than SHA-256, but it is not widely used as of now. It is computed with 64-bit words.

Is SHA-3 the same as Keccak? ›

SHA-3 is a subset of the broader cryptographic primitive family Keccak (/ˈkɛtʃæk/ or /ˈkɛtʃɑːk/), designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche, building upon RadioGatún.

Is SHA-256 the same as AES 256? ›

SHA256 and AES256 are not equivalent in terms of their functionality and purpose. While SHA256 is a cryptographic hash function that generates a fixed-size output (256 bits) from any input data, AES256 is a symmetric encryption algorithm that utilizes a 256-bit key for data encryption and decryption.

What is a Keccak hash? ›

Keccak is a versatile cryptographic function. Best known as a hash function, it nevertheless can also be used for authentication, (authenticated) encryption and pseudo-random number generation.

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 5991

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.