-1

So I'm learning about hashing in Windows Batchfile and I was wondering if there is a simple way to unhash hashed text.

To hash the text, I have been using this:

set /p input=Text: 

echo %input%>%temp%\hashinput.tmp
CertUtil -hashfile %temp%\hashinput.tmp sha256 | findstr /v "hash">%temp%\hashoutput.tmp
set /p output=<%temp%\hashoutput.tmp

del %temp%\hashinput.tmp
del %temp%\hashoutput.tmp

echo %output%

All it's doing is sending the user input to a temporary file, hashing it and sending that to a temporary file and setting a variable to the output before removing the files.

After some looking around I, have been unable to find a way to unhash text using CertUtil or any other commands. If there is an easy way I would love to know how.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Immortal
  • 35
  • 6
  • 2
    What the hell is "unhashing"?? You seem to confuse "hashing" encryption or something. To compute a hash of a file means to generate a fingerprint of that file in order to become able to verify the validity/completeness of the file. You cannot reverse that process to get a file out of a hash. A hash has a certain length (SHA-256 uses 256 bits), independent on the length of the file you derive it from, so a file may contain much more information than the hash (just as an additional argument for why it is irreversible)… – aschipfl Dec 14 '21 at 12:35

1 Answers1

3

There is no feasible way to get the original input from the hash, that is the whole point. You can try brute force by trying all possible inputs but that is not practical, it will take way too much time.

Another name for a hash is a one-way function...

Anders
  • 97,548
  • 12
  • 110
  • 164