0
votes

I know is it impossible to decrypt an MD5 hash. However, I am trying to solve a riddle game and a lot of the hints are encrypted with MD5. As I cannot find some of the encrypted words on google, I was wondering whether it is possible to make a C++ program that would store common English words and their encryptions and when given a certain encryption search the answer.

EDIT: The hints are words, not phrases.

4
It's unlikely that hints are stored as MD5 hashes, because the program will never be able to recover them. How did you arrive at that conclusion?sinelaw
Or perhaps instead of hints you meant "answers"? If the user has to enter the full answer and the program just checks that it's the correct one, then a hash function (e.g. MD5) could be used. But if you are referring to hints that are shown to the user, they must be stored in a different way.sinelaw
@sinelaw The words of the hints are encrypted as MD5 hashes,not complete phrases.M.Ritz
that still doesn't make sense. Also individual words will not be recoverable.sinelaw

4 Answers

3
votes

It's not an encryption, it's a secure hash function: it is designed to be one way only. And there is no way given a hash to tell it the original input string contained some word; you need to guess the entire hint perfectly or you get no information.

But if the hints are just words then you could certainly build up a table of hashes of candidate words and search in it for a given hash; that would be fairly easy.

2
votes

As mentioned, a hash is a mathematical function that cannot be reversed. So it's not possible to "decrypt" a hash.

However, as you guessed, it's perfectly fine to calculate the hashes of suspected results and compare your hash against it. In real-world scenarios, there would be a salt used to make this impossible, but since it's a kind of test, you can use a rainbow table for this.

0
votes

The way you decrypt hashes is to generate one based on a string, and compare the result with the hash that you have.

If you know for example that the game uses only letters, then you could create a table with all the combination of the alphabet, take this database and hash them using MD5, and then compare them with the hash that you have.

You can do this in any programming language you want, just google: md5 hash "language". And you will find a ready to use function for hashing. Then you just have to write:

  • the code to generate a database of possible words,
  • hash those words
  • compare the hashes with the one that you have

Hope this helps.

-1
votes

A MD5 hash is, like the word says a type of hash function. A hash function is a function which displays the input on a much smaller output range. It is also a one way function, it is not possible to "dehash" something

An example:

Input: All possible characters Output: A number between 0 and 1 million.

(1 million is definitely enough, see http://www.oxforddictionaries.com/words/how-many-words-are-there-in-the-english-language)

So say you are hashing a text, every word can be displayed on a number. Hash functions normally do not garantee that a word will not be displayed on the same number. But since there are much more words which do not make sense, the hash function will work most of the time