Jump to content

[SOLVED] encrypt function hangs


deanb61

Recommended Posts

I jsut inherited an application. Works fine on the machine it came from. On my pc is just hangs. I've traced it to the statement:

 

$password=encrypt($_REQUEST['password']);

 

Which calls:

 

//encryption function

function encrypt($encrypt) {

  global $key;

  $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);

  $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, MCRYPT_MODE_ECB, $iv);

  $encode = base64_encode($passcrypt);

return $encode;

}

 

php 5 and apache 2 on windows. Any ideas?

 

Thanks,

Dean

Link to comment
https://forums.phpfreaks.com/topic/63469-solved-encrypt-function-hangs/
Share on other sites

How did you trace it to that function, and exactly which line of the function does it hang on?

It's the login page of the application. Enter user name and password, hit the login button, and all that shows is a blank white page.

 

I traced it to this function like so:

 

function process_customer(){

global $sessionid, $today, $database_name;

 

            echo"<p>doing process customer</p>";

 

$email=strtolower($_REQUEST['email']);

            $pass=$_REQUEST['password'];

            echo"

            <p>password: $pass</p>

            ";

$password=encrypt($_REQUEST['password']);

            echo"

            encrypted password

            ";

$company=$_REQUEST['company'];

$screen_width= $_REQUEST['screen_width'];

$screen_height= $_REQUEST['screen_height'];

            echo"

            <p>Variables set</p>

            ";

 

This first echo now appears on the blank white page, it says 'Password: fred', but nothing else, so I'm assuming the encrypt function isn't working.

 

Although an experience programmer, I'm not a PHP expert. This is working on one machine and I just copied the files over to my machine. I had one problem where the latest version of PHP doesn't seem to work with the latest version of Apache, so I installed a previous version of appache (v2) and stayed with PHP 5, I'm not sure if the original machine is running PHP5 however.

Have you tried taht encryption class I've just posted ??

Not yet sorry, I've been doing some more digging. On the PC where this came from, there is a file libmcrypt.dll, this does not exist on my PC.

 

I have a database which already has passwords encrypted using mcrypt. Will it be ok to use your encryption class in this case? I'll give it a go and see. First I might just try copying the libmcrypt.dll and see if that solves the problem.

I have a database which already has passwords encrypted using mcrypt. Will it be ok to use your encryption class in this case?
No it wouldnt work with mcrypt.

you need to install it correctly.

First check your phpinfo() output.

then uncomment your php.ini's mcrypt loader line.

then restart.

Thanks, yes definately the problem. I don't know why it wasn't reporting it, but mcrypt is not installed on this PC. As you probably know copying the dll didn't work, so I guess I'll have to install it properly. I'll have a look at phpinfo(), and at the php.ini. I know it's there, but I haven't looked at it at all. As I said, although I'm an experienced programmer, I don't know php.

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.