TransWikia.com

Is it possible to brute-force the original message of SHA-256 given the size of original string?

Information Security Asked on November 6, 2021

Given the SHA-256 hash, the size and the encoding of the original string, is it possible to recover the string via brute force? How many string of a given size will result in the same hash?

2 Answers

Given the original length L of the string, you could consider that the effort to retrieve it is 92 power L (92 is 26 lowercase + 26 uppercase + 10 digits + 30 punctuation) instead of 2 power 256.

So if your string is more than 39 chars long, knowing the lenght gives no help.

EDIT: we should consider that an opponent which tries to recover the original string will not actually bruteforce each character. He will bruteforce words.
Except if the string contains a random password, an unknown lastname or something else which is not in a dictionnary, this is the best approach.
With an upper bound of 1,022,000 words and a lower bounds of 171,476 words (words currently used) the order of magnitude can be calculated by 1000000 power N (N is the number of words in the string).
So if the sentence is less than 13 words long, it could be broken before the hash.
However, we have to consider that all the words permutations are not relevant. the opponent could use a smart approach in the building of the candidates to avoid meaningless sentences (for example testing "the" after another "the" could be avoid, testing "than" after "most" makes no sense too).
Following this approach, knowing the number of characters of the string is helpful for the opponent because it will exclude many candidates.
But I'm not sure that the time spent to test the length and the meaningfulness of the sentence is not bigger than just hash it and compare it.

Answered by Sibwara on November 6, 2021

There are 2^256 hashes, so approximately 1 in 2^256 strings will have a particular hash.

Therefore the number of strings with that hash is approximately the total number of strings divided by 2^256.

How long is the length? There are a lot of strings to try. You'd have to use up all of the sun's energy just to count to 2^256, never mind hashing. But if the length is only 32 bits, you only have to try 2^32 strings which is a lot less.

Answered by user253751 on November 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP