T
T
termo5002019-02-06 14:27:32
Hashing
termo500, 2019-02-06 14:27:32

Is dehashing possible under certain conditions?

Hello. Recently, the question has arisen whether dehashing can be done. Having climbed a bunch of sites, I realized that "hashing is an irreversible process", "dehashing is impossible" and so on, but nowhere was it explained why. I began to dig deeper and found out that hashing is irreversible for the reason that the "initial character set" is larger than the final one. That is, when hashing, the character set is reduced to 16 (from 0 to f) and when trying to return, it turns out that for each hash character (from 0 to f) there are almost six possible source characters (0-9, az, and -i, etc.). Question: if it is known for sure that the h1 hash was hashed (sha-256 for example) and the h2 hash was obtained from it (the same sha-256 - i.e. the number of characters at the beginning is equal to the number of characters at the end,
PS Yes, I know, hashing is based on methods of irreversible mathematics like "you cannot find a number, knowing only that its remainder after dividing by 3 is 1", but I understood the process of hashing itself (an article on Habré bitcoin mining manually) and understood , that in theory, knowing that the final set of characters is equal to the initial one (from 0 to f) and, moreover, is equal in length (64 characters), one can, so to speak, impose a restriction that this unknown number, for example, is not more than 10 (this is an abstract example , I know that everything is different in the algorithm), and based on this, generate four possible h1 hashes (again, abstract).

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Denis Zagaevsky, 2019-02-06
@zagayevskiy

You can pick it up, it's 16^64 = 2^256 combinations.
Algorithm:

for (i = 0; i < 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; ++i) {
   if (sha256(i) == your_hash) return i
}

In total, there are 115792089237316195423570985008687907853269984665640564039457584007913129639936 options.
No, you can't, of course. They were invented for this, so that it could not be done. Symbols are not mapped one into another, in the general case there are no "almost six possible initial symbols" there. An infinite set is mapped to a finite set.

R
Rsa97, 2019-02-06
@Rsa97

Hashing, in general, is irreversible, because the hashing algorithm itself does not guarantee a one-to-one correspondence between the source data and its hash.
If the source data is larger than the hash, then it is obvious that there are several different source data with the same hashes. For example, the hash function produces 0 or 1 (one bit), and the input received numbers from 0 to 7 (three bits).
If the data size is less than or equal to the hash size, then depends on the algorithm. Industrial algorithms are built with good hash distribution uniformity, so it can be assumed that the hash function has an approximately one-to-one correspondence on such data.
But, in any case, the hash function does not have a simple inverse transformation algorithm.

A
Armenian Radio, 2019-02-06
@gbg

Hashing is irreversible for another reason - there are a lot of irreversible steps involved in computing a hash.
For example, the simplest hash in the world is to add all the original bytes
1+2+3=6
Hash = 6, but to restore back the original bytes 1 2 3, all that remains is to sit and pick. all possible candidates.
Well, yes, this is an example of an extremely banal hash with a bunch of collisions

R
Roman Kitaev, 2019-02-06
@deliro

Hashing is an irreversible process. But no one bothers to go through all the options until you find a match. Indeed, it is very long.
Lies. The hash alphabet is zeros and ones. The alphabet of the input data is zeros and ones. The power of a hash is only determined by the number of bits it generates. And how you represent these bits - in the form of HEX, in binary form, or in the form of suns and clouds - is your business and does not affect the process in any way.
You can, it's enough to go through all the possible values ​​of h1 until you get h2. For sha256 it's 2^256 options.

J
jcmvbkbc, 2019-02-06
@jcmvbkbc

if it is known for sure that the hash h1 was hashed and the hash h2 was obtained from it, the number of characters at the beginning is equal to the number of characters at the end, moreover, the set of characters in the first expression is equal to the set of characters in the second expression, is it possible, having h2 on hand, to return the value hash h1?

Yes, if the hash is bijective. But for a good hashing algorithm, there is no way to do this much faster than iterating over all possible values ​​of h1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question