16

By using an online tool and wikipedia I found out that every sha-256 encrypted string is 64 chars longs containing numbers and characters. Hence I assumed that there are 34^36 combinations ( 2^216 simplified by an algebra calculator ). After doing some research I found out that most people said there are 2^256 combinations. Could someone explain ? To make the context clear, I write a paper about cryptocurrencies and try to explain how many different combinations there are to encrypt and how long this could take ( therefore how many guesses it could take) and compare this to the amount of total atoms in the universe (roughly 10^85).

WoffeLL
  • 163
  • 1
  • 1
  • 4
  • 1
    Not sure where 34^36 or 2^216 comes from. – zaph Mar 27 '18 at 19:22
  • While 10^77 and 10^85 are large numbers they are small compared to a [google](https://en.wikipedia.org/wiki/Googol): 10^100 and then there is a [googleplex](https://en.wikipedia.org/wiki/Googolplex): 10^google or 10^(10^100) – zaph Mar 27 '18 at 19:39

3 Answers3

34

SHA-256 produces 256 bits which is 32 bytes, not characters, each byte has 256 possible values.

There are 256 bits and each bit has 2 values (0 or 1), thus 2^256.
There are 32 bytes and each byte has 256 values, thus 256^32.
Note: 2^256 == 256^32 ~= 10^77.

The 32 bytes can be encoded many ways, in hexadecimal it would be 64 characters, in Base64 it would be 44 characters.

zaph
  • 111,848
  • 21
  • 189
  • 228
  • can I think of it like this: 16 unique digits in hex, sha256 is 64 characters, 16 possible digit for each of the 64 slots, which is 16^64 = (2^4)^64 = 2^256 – xgg Nov 01 '18 at 21:19
29

Total combinations of SHA-256 is

115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
Dinesh DiNu
  • 681
  • 5
  • 16
  • 5
    Not actually *very* useful, but fun to see the answer in "long form" to get a direct visual idea of how big the number is. Too bad peeps down voted - unless the value is wrong? (I didn't actually check... lololol) – Stevel Oct 06 '20 at 22:36
6

A sha-256 hash has 64 characters, 32 hex combinations, because a hex has 2 characters.

3a 7b d3 e2 36 0a 3d 29 ee a4 36 fc fb 7e 44 c7 35 d1 17 c4 2d 1c 18 35 42 0b 6b 99 42 dd 4f 1b

Above is a hash where the hex combinations are separated so you can count 32.

There are 16 characters available to hex 0-9&a-f and 16^2 or 256 combinations in hex.

With 32 slots for a hex in a sha-256 you use 256^32 to get:

115792089237316195423570985008687907853269984665640564039457584007913129639936

Available sha-256 hashes.

Tyler Stein
  • 69
  • 1
  • 2