Jump to content

Question about mcrypt


Simmo

Recommended Posts

Hi

I  plan to use this function to encrypt and decrypt:

function encryptData($data, $p) {
  $iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB),
MCRYPT_RAND);
  $sEncrypted = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $p, $data, MCRYPT_MODE_ECB,
$iIV);
  return(base64_encode($sEncrypted));
}

function decryptData($data, $p) {
  $data = base64_decode($data);
  $iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
MCRYPT_RAND);
  $sDecrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $p, $data, MCRYPT_MODE_ECB, $iIV);
  return(trim($sDecrypted));
}

I read somewhere that using the base64_encode is easily decrypted.  I have not used this sort of code before but from what I see it is encrypted first with mcrypt and then the base64 is added for good measure.

If I am right then it is encrypted really well and is just what I am after, so if someone can put me straight I would be greatful.

Thanks
Link to comment
https://forums.phpfreaks.com/topic/30974-question-about-mcrypt/
Share on other sites

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.