SHA-256

SHA-256

SHA-256 is a computational procedure that generates a fixed sequence of 256 digits from arbitrary data – a digital fingerprint. Even a single changed digit in the input leads to a completely different result, and the input cannot be reconstructed from the result.

SHA-256 is a fixed computational rule. You feed data into it: a text, a password, an entire file. What comes out is always a number with 256 binary digits, usually written as 64 characters made up of digits and letters. This output is called a hash value or fingerprint of the data. It is always the same length, regardless of whether the input was three letters or an entire movie. And it only works in one direction: the fingerprint can easily be calculated from the data, but the original data can practically no longer be reconstructed from the fingerprint.

Why a fingerprint made of 64 characters is so useful

The most important use is comparison. Anyone who wants to check whether two files are identical does not need to go through them byte by byte. It’s enough to compare both hash values. If they match, the files are identical with near certainty. If they differ, something was changed somewhere.

This leads to the second use: manipulations become noticeable. A download provider publishes the SHA-256 value alongside the file. After downloading, anyone can recalculate it themselves. If the value doesn’t match, the file was altered in transit or is damaged. This is exactly why SHA-256 is used in software updates, digital signatures, and blockchains.

A common misconception is that SHA-256 is a form of encryption. It is not. Encrypted data can be made readable again with the right key. A hash value, by contrast, is final – the information is gone. That’s why services store passwords as hash values: even if attackers steal the database, they don’t have the passwords themselves.

From data block to 64-character result

SHA-256 first breaks the input down into blocks of 512 bits each, i.e. 64 characters of raw data. If the last block is too short, it is padded according to fixed rules. In doing so, the total length of the input is also written in. The procedure then starts with eight predefined starting numbers.

Each block is processed in 64 rounds. In each round, the numbers are added, shifted bitwise, and combined with one another. These operations are simple individually, but they mix the information so thoroughly that every input bit affects the entire result. The result of one block flows in as the starting value for the next block. After the last block, the eight numbers are fixed – written together, they form the hash value.

The most important effect is called the avalanche effect. If you change a single letter in a long text, the new hash value looks completely different. There is no similarity from which the small change could be read. In theory, two different inputs must eventually share the same value at some point, since there are infinitely many inputs but only finitely many hash values. However, no one has managed to produce such collisions in SHA-256 to this day, because the number of possible values, at around 10 to the power of 77, is unimaginably large.

Bitcoin, passwords, and the everyday life of checksums

SHA-256 is best known through Bitcoin. In so-called mining, computers search for a number that, together with the new transactions, produces a hash value with a great many zeros at the beginning. This can only be found through sheer trial and error, billions of times per second. It is precisely this trial and error that consumes the electricity reported on in the news. Dedicated chips have been developed for this purpose that can do nothing other than compute SHA-256.

In quieter everyday life, one encounters the procedure constantly without noticing it. Every encrypted connection in the browser checks certificates that are secured with SHA-256. Linux distributions and programs like password managers publish checksums for their downloads. Git, the version control system behind almost all software development, names data states via hash values.

For passwords, however, a limitation applies. SHA-256 is deliberately very fast – and this helps attackers who try out millions of candidates per second. Serious services therefore deliberately use slow procedures like bcrypt or Argon2 and mix in a random value. In news reports about data leaks, a mention of unsalted SHA-256 hashes is therefore rather a bad sign.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.