1

I generate md5 hashing and convert to hexadecimal value. Is there a way i can reverse back from hexadecimal value to original text in python

import base64
import hashlib

def md5_hash(plain_text):
    return hashlib.md5(plain_text.encode()).hexdigest()

md5_hash('123456')

md5 generated hexdecimal value of the text 'e10adc3949ba59abbe56e057f20f883e'

Jtcruthers
  • 854
  • 1
  • 6
  • 23

2 Answers2

1

You cannot reverse hashes. They aren't encryptions. Hashes (md5, sha256, etc.) are one-way. They can only go from x -> y, and there's no way to go backwards y -> x. There can be multiple values that reduce to the same hash (called collisions), where md5(value1) -> x AND md5(value2) -> x. This makes it impossible to determine what the original value was from a hash.

More reading for you

Jtcruthers
  • 854
  • 1
  • 6
  • 23
  • Can i hash (SHA 512) the ASCII characters of the text and then try to retrieve it back. – Alice Smith Oct 14 '19 at 18:46
  • You cannot retrieve anything from a hash, no. There are multiple ASCII characters that could result in the same hash, so there's no way to know for sure which characters resulted in said hash. – Jtcruthers Oct 14 '19 at 18:47
0

The hashing whole purpose is to never allow you to get back your original string.

What you can do it try to apply md5 to a lot of strings, and see if, by chance, one of these strings has the same hash as your final hash and then you can conclude that this string may be the string that generated your first md5 hash. (because as information is lost while hashing, you might encounter 2 different strings giving the same hash)

Maxime
  • 818
  • 6
  • 24