Hi there,

please help me to write script encryption/decryption in php?
i am using below code for my encryption/decryption ...
Please tell your suggesstions if there is security issues in this script.
thanks..

$key_value = "prtiv24$";    
$plain_text = "password"; 
$encrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $plain_text, MCRYPT_ENCRYPT); // password encryption 
echo ( $encrypted_text ); 
$decrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $encrypted_text, MCRYPT_DECRYPT); 
echo ("<p><b> Text after decryption : </b>"); 
echo ( $decrypted_text ); 

Hi,

just a note: the mcrypt_ecb() function is deprecated since PHP 5.5, it means this is going to be removed. You should use mcrypt_generic()and mdecrypt_generic() as explained in the documentation:

For some information about the encryption modes check those available:

I would use CBC rather than EBC, because with EBC is possible to find patterns and it is possible to alter the encrypted string to obtain something else. This article explains the issue very well:

Bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.