When using this encryption function i get the error:

Notice: Use of undefined constant blowfish - assumed 'blowfish' in /home/w3stuff/public_html/lib/stdlib.php on line 216

anyone know how to solve this?


function encrypt($input,$key){
/* Encrypt - note $key must be supplied */

  $iv = mcrypt_create_iv (mcrypt_get_iv_size (blowfish, MCRYPT_MODE_ECB), MCRYPT_RAND);
  $encrypted = mcrypt_encrypt (blowfish, $key, $input, MCRYPT_MODE_ECB, $iv);
  $encrypted = base64_encode($encrypted);
  return $encrypted;
} 


function decrypt($input,$key){
/* decrypt - $key must be same when encrypting to decrypt */

  $decrypted = base64_decode($input);
  $iv = mcrypt_create_iv (mcrypt_get_iv_size (blowfish, MCRYPT_MODE_ECB), MCRYPT_RAND);
  $decrypted = mcrypt_decrypt (blowfish, $key, $decrypted, MCRYPT_MODE_ECB, $iv);
  return $decrypted;
}

xeelee thanks

    if blowfish isnt a constant put quotes around it

      Thanks sidney!

      it works like a charm!🙂

        Write a Reply...