Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    470
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Mcrypt not decrypting the first eight characters

    I am using the following to encrypt and decrypt a simple multiline string.

    PHP Code:
    $riv_size mcrypt_get_iv_size(MCRYPT_BLOWFISHMCRYPT_MODE_CBC);
    $riv mcrypt_create_iv($riv_sizeMCRYPT_RAND);

    if (
    $operation == 'decrypt')
         
    $string rtrim(mcrypt_decrypt(MCRYPT_BLOWFISH$crypt_keybase64_decode($string), MCRYPT_MODE_CBC$riv));
    elseif (
    $operation == 'encrypt')
         
    $string base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH$crypt_key$stringMCRYPT_MODE_CBC$riv)); 
    However, upon decrypting the string, the first eight characters remain garbled as if they are still encrypted. This is the first time I have ever encountered this problem and I have used mcrypt before in other scripts without the first eight characters remaining encrypted. Why would this happen?

    Currently I am having to pad the string with spaces to the left each time to get around this problem and then strip them after decrypting.
    Last edited by bauhsoj; 06-16-2005 at 05:47 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •