Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is a there md5 decrypt function in python? [duplicate]

Tags:

python

md5

Possible Duplicate:
Is it possible to decrypt md5 hashes?

i used md5.new(); md5.update("aaa"), md5.digest()

to form a md5 hash of the data "aaa" . How to get back the data using python?

like image 254
Hick Avatar asked May 03 '10 20:05

Hick


People also ask

Is there any way to decrypt MD5?

The MD5 cryptographic algorithm is not reversible i.e. We cannot decrypt a hash value created by the MD5 to get the input back to its original value. So there is no way to decrypt an MD5 password.

What is the MD5 function in Python?

The MD5, defined in RFC 1321, is a hash algorithm to turn inputs into a fixed 128-bit (16 bytes) length of the hash value. MD5 is not collision-resistant – Two different inputs may producing the same hash value.

Can MD5 be cracked?

The MD5 message-digest algorithm is a cryptographically broken but still widely used hash function producing a 128-bit hash value. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities.


3 Answers

You cannot decode an md5 hash, as hashing is a process that is best thought of as one-way encoding (that is to say what is hashed cannot be de-hashed; one can only determine what was hashed, either by examining a list of known hashes, or by hashing a set of inputs and matching the resulting hashes with the hash you are trying to "decode").

Quoting Wikipedia, the key features of such a hashing algorithm are:

it is infeasible to find a message that has a given hash,

it is infeasible to modify a message without changing its hash,

it is infeasible to find two different messages with the same hash.

The most common uses of such algorithms today are:

  • Storing passwords
  • Verifying the contents of files.

If you want to two-way encrypt the data, you need to look at other cryptographic libraries for Python (As usual, Stackoverflow has a recommendation).

like image 59
Sean Vieira Avatar answered Sep 30 '22 08:09

Sean Vieira


You can't. That's the point - a hash is one-way, it's not the same as an encryption.

like image 25
BlueRaja - Danny Pflughoeft Avatar answered Sep 30 '22 10:09

BlueRaja - Danny Pflughoeft


I don't know about Python - but hash function are irreversible. First of all, note that hash functions provide a constant length output - meaning that information will be thrown away (you can hash a file of 3 MB and still only get a result of less than 1 kB). Additionally, hash functions are made for the fact that they aren't reversible, if you need encryption, don't use hashing but encryption - a major application of hashing is when the database info has leaked (which contained hashes) that the passwords have not been compromised (there are more examples, but this is the most obvious one)

like image 31
Jasper Avatar answered Sep 30 '22 09:09

Jasper