0

Possible Duplicate:
PHP 2-way encryption: I need to store passwords that can be retrieved

I am working with encrypt the password:

   php> echo bin2hex(mhash(MHASH_SHA1,'test'));
    a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

My question is if I have a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 How Can I get back the test.

Are the function to de-encrypt?

Community
  • 1
  • 1
sophie
  • 1,485
  • 6
  • 18
  • 30

3 Answers3

1

your have to understand the diff between a hash function an encryption.

Hashes are one way. You can't convert back. Checking passwords on login usually works by hashing the password from login, too and then just check if hashes are the same.

mblaettermann
  • 1,903
  • 2
  • 17
  • 23
0

Using SHA1 it is easy to convert some text into a hash, but going the other way is very, very time consuming, which is one reason why it's good to use for encryption, and in your example passwords.

You may have some luck with this site -

http://www.md5decrypter.co.uk/sha1-decrypt.aspx

It has a list of common hashes and your example 'test' was easily found.

Angelom
  • 2,283
  • 1
  • 14
  • 7
  • That website uses brute-force to decrypt, it nothing but a large database of hashes with the original string. – SERPRO Oct 17 '11 at 10:44
0

Why do you want to decode the hash output? You can check the password by hash, instead of trying to decode it. By the way, you can't decode a hash, because it loses information when it gets coded. if you want to encrypt/decrypt you should use MCrypt or another encryption class

SERPRO
  • 9,867
  • 7
  • 44
  • 63