Encryption / decryption


Hi all can some one give me a good simple example for encrypting/de-crypting what i am after is:-

$key = ‘secret word’; // to encrypt by

$string = ‘this is the text to be encrypted’; //text to be encrypted

$encrypted = $string encrypted, //encrypted string

then i want to be able to do the opposite

$key = ‘secret word’; // to de-crypt by

$encrypted = $string encrypted, //encrypted string

$string = ‘this is the text to be encrypted’; //de-crypted string


google it, there are thousend of scripts or use base64_encode() base64_decode() :slight_smile:


MD5 seems to work well… Here is a link for details… Please look at the posts down the page a little…



MD5 is an algorythm and is just one way coding, you cannot decode you can just compare the coded strings…


Like andru says, md5 is a hashing algorithm, tis is not what you are looking for.
and he noted that they plentiful scripts out there that are available, as well as the base64 already in php.

of course building an encoding system is relatively trivial, from a simple XOR encryption.

but if you are looking for a pre-made system
take a look at PHPClasses and HotScripts


Yes, MD5 is a HASH, but, he only wanted it for a password, not to do real encryption.
So, he could hash the password and save the hash. Using a key that only he knows, how would it matter?

Well, it was just an idea…


Note, the statement about reversing the procedure.


Well, I sort of agree. But, he is only talking about one small password, not data!

So, md5($password+$secretword+MYsecretword) is very secure… First, the user types the secret word and password in, you add another layer and then MD5 it… Compare it to your database where you store this before, and it is very safe! Hard to break. Nobody can ever see what YOUR secret side of the code is… So, safe safe sage… Yes, full encryption would be even safer, but, just for a simple password, not needed…

Well, in my humble opinion...