I am using code $enrypt=md5($pass)
and inserting $encrypt
to database. I want to find out a way to decrypt them. I tried using a decrypting software but it says the hash should be of exactly 16 bytes. is there any way to decrypt it or to make it a 16 byte md5 hash?
My hash looks like this: c4ca4238a0b923820dcc
There is no way to decrypt MD5. Well, there is, but no reasonable way to do it. That's kind of the point.
To check if someone is entering the correct password, you need to MD5 whatever the user entered, and see if it matches what you have in the database.
It's not possible to decrypt
MD5
hash which created. You need all information to decrypt theMD5
value which was used during encryption.You can use
AES
algorithm to encrypt and decryptJavaScript AES encryption and decryption (Advanced Encryption Standard)
Hashes can not be decrypted check this out.
If you want to encrypt-decrypt, use a two way encryption function of your database like - AES_ENCRYPT (in MySQL).
But I'll suggest CRYPT_BLOWFISH algorithm for storing password. Read this- http://php.net/manual/en/function.crypt.php and http://us2.php.net/manual/en/function.password-hash.php
For Blowfish by
crypt()
function -password_hash
will be introduced in PHP 5.5.Once you have stored the password, you can then check if the user has entered correct password by hashing it again and comparing it with the stored value.
As already stated, you cannot decrypt MD5 without attempting something like brute force hacking which is extremely resource intensive, not practical, and unethical.
However you could use something like this to encrypt / decrypt passwords/etc safely:
Using a encypted method with a salt would be even safer, but this would be a good next step past just using a MD5 hash.
This question is tagged with PHP. But many people are using Laravel framework now. It might help somebody in future. That's why I answering for Laravel. It's more easy to encrypt and decrypt with internal functions.
But you should not use encrypt and decrypt for authentication. Rather you should use hash make and check.
To store password in database, make hash of password and then save.
To verify password, get password stored of account from database