Jump to content

encrypt private messages


ryan14

Recommended Posts

Sure, but md5 is not the way to go. Base64 should also be avoided, it is not encryption but rather encoding and anyone with any type of familiarity with it will recognize it and easily decode it.

 

You need something a bit stronger. Try playing with this, its a blowfish encryption example and all you need to get going to implement something that will withstand even the NSA(at least for a while). You can also md5 the key and use it the same way you would a password for more security.

 

$cc = 'it was the best of times...it was the worst of times...it was a psychedelic roller coaster';
$key = 'my secret key yek terces ym';// the stronger the better
$iv = '12345678';// must be 8 bit length

$cipher = mcrypt_module_open(MCRYPT_BLOWFISH,'','cbc','');

mcrypt_generic_init($cipher, $key, $iv);
$encrypted = mcrypt_generic($cipher,$cc);
mcrypt_generic_deinit($cipher);

mcrypt_generic_init($cipher, $key, $iv);
$decrypted = mdecrypt_generic($cipher,$encrypted);
mcrypt_generic_deinit($cipher);

echo "encrypted : ".$encrypted;
echo "<br>";
$decrypted=rtrim($decrypted,"\0");
echo "decrypted : $decrypted";

 

 

HTH

Teamatomic

Just pass your sting to sha1($string); or md5($string);  8)

 

Then how will the user read it later?

 

sorry actually i forgot that md5 and sha1 are one way encryption !  :-[ . anyways  is there any way in php with two way encryption except for ur own algorithm  ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.