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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.