So there are times that I am in the need to encrypt data with the capability of decryption afterwards so md5 is not capable for me to use.
$data = "Data to encrypt.";
$encryption_key = md5( $pass );
$encrypted_data = encrypt( $data, $encryption_key );
$decrypted_data = decrypt( $encrypted_data , $encryption_key );
function encrypt($string, $key){
$string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
return $string;
}
function decrypt($string, $key){
$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
return $string;
}