Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrypt MD5 in Ruby? [duplicate]

Tags:

ruby

md5

Possible Duplicate:
Is it possible to decrypt md5 hashes?

I do this in Ruby:

Digest::MD5.hexdigest("Jose")

and get "70483b6e100c9cebbffcdc62dea07eda"

But, how do I decrypt it back to "Jose"?

like image 499
Voldemort Avatar asked Aug 02 '11 03:08

Voldemort


1 Answers

MD5 is a hashing algorithm, you can not easily decrypt the output back to the original (and this is exactly why we use hashing algorithms).

A common example is passwords. Instead of storing a password in your database, you generate a MD5 hash of the original password and store it. If one day someone steals your database it's harder for them to figure out the real passwords, as they can not be directly decrypted.

But when you're trying to login a user, he's going to type the real password, you will then run the MD5 algorithm again and compare the hash with the one you have stored, if they're the same then the user possibly typed the correct password.

like image 191
Maurício Linhares Avatar answered Sep 20 '22 14:09

Maurício Linhares