Short answer: this is not possible.
Because SHA-1 is a cryptographic hash function , the pigeonhole principle is mathematically impossible to reverse. There are only 2,260 possible SHA-1 hashes. Since there are an infinite number of possible input lines, there must be collisions (multiple inputs whose hash has the same value). In general, there is no way to find out which of these lines was the original.
However, the lines of the real world are not completely arbitrary. If you know some information about your input string (for example, it was less than 5 characters), it is likely that the input is unique. Unfortunately for you, hash functions such as SHA-1 are intentionally computationally invalid for inversion. (There are theoretical attacks on SHA-1, but I do not think that they are currently considered even practicable.)
So, if you need to recover the hashed data, you should use brute force: try SHA-1 for each line less than n long and see if the hash matches. But there are exponentially many lines of length up to n, so this quickly becomes impracticable.
There is one possible way to recover hashed data to the end of the universe . Your only hope is to use a more sophisticated method, such as rainbow tables . This will only work if you know that your original line was very short (less than ~ 15 characters). Even for short lines, a preliminary calculation of the table will take a lot of time (and gigabytes of disk space).
Mechanical snail
source share