Question on md5() and others

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed Aug 08, 2012 7:32 am

Question on md5() and others

Postby KS30 » Wed Aug 08, 2012 7:40 am

Hi All,
I recently used the function md5() to secure a password on a form I had to create. I found there were other functions such as crc32() or sha1(). Is md5() the most secure and if so why would you use the others?

Thank you!!

User avatar
php-forum Active User
php-forum Active User
Posts: 335
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: Question on md5() and others

Postby freshnet » Fri Aug 10, 2012 4:57 am

md5 is not very secure. You're better of using something like bcrypt:

Code: Select all

$key = 'password to (en/de)crypt';
$string = 'string to be encrypted ';

$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests