lundi 10 juillet 2017

July 7th, 2017

Secure Hash Algorithm 2 (SHA-2) is a cryptographic algorithm which converts any text to binary. This may sound fairly unimpressive, however there are a few interesting qualities. Firstly, no matter how massive the text input (even an entire book), the binary output will always have a length of 256. As an example, converting 'hi' returns the output:

8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4

which is in hexadecimal. This can be then changed to binary, which gives:

1000 1111 0100 0011 0100 0011 0100 0110 0110 0100 1000 1111 0110 1011 1001 0110 1101 1111 1000 1001 1101 1101 1010 1001 0000 0001 1100 0101 0001 0111 0110 1011 0001 0000 1010 0110 1101 1000 0011 1001 0110 0001 1101 1101 0011 1100 0001 1010 1100 1000 1000 1011 0101 1001 1011 0010 1101 1100 0011 0010 0111 1010 1010 0100

If you count all the 0s and 1s, there are indeed 256. SHA-2 is also 'collision resistant'. This means that, although you can use anything of any length as input, and your output is always 256 zeros and ones, it is practically impossible to find two different inputs that give the same output. How is this possible? Well, the number of different possible outputs for 256 characters that can be either 0 or 1 is $2^{256}$. This is roughly equal to:

$10^{77} =~$100 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

This enormous number of possible outputs makes it nearly impossible to find two inputs that generate the same output. That it is very quick and easy to calculate the output of a given input, but effectively impossible to go the other way, makes SHA-2 the current standard for computer encryption. It also plays a pivotal role in online currencies (cryptocurrencies), such as bitcoin.

-E

Aucun commentaire:

Enregistrer un commentaire