Question on md5() and others

General discussions related to php

Moderators: egami, macek, gesf

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

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");

Post Reply