Page 1 of 1

Encryption using C language in PHP environment?

Posted: Sun Jan 11, 2004 5:50 pm
by shaky
Hi Again!

Can anybody explain to me step by step what i have to do to integrate C in PHP 'coz i've try to read the php manual u guys suggested, especially
http://www.php.net/manual/en/zend.php. It is to complicated for me to understand especially now i'm running out of time.

I'm using php 4.2.3...
Actually, my project is to develop a consultancy info system, where user have to enter their username and password to use the system (in php environment). So then i want to encrypt the password using an algorithm called ECC in C language. That is why i need to integrate C in PHP.

Do you think that's possible? i mean i want to sent the password which user entered to the C program to be encrypt and then send it back to the php program to compare it with the password in the database.

Please help me! I need to know what setting i have to do?
Can i just use Borland Turbo C++? I've try to run simple extension tokenzier using Turbo C++ as suggested by mr. volka, but there are so many error like "unable to open include file PHP.h"!

What can i do? Is there any setting that i need to do first?
Or is there any ECC(elliptic curve crypto) written in PHP?

Thanks :)

Posted: Sun Jan 11, 2004 6:00 pm
by Sevengraff
If you compile the c program into an executable, you can call it and get the output of it with shell_exec

Code: Select all

$encrypted = shell_exec("/bin/ecc_thing $password");
just make your program output the ecc encrypted password and php should be able to grab it.

Posted: Sun Jan 11, 2004 6:48 pm
by Pyrite
Or since you know the algorithm, can't you just convert it to PHP, cause PHP can do damn near about everything C can do and more.

You can write an extension for PHP in C and load it with dl().
http://us4.php.net/dl

Pointing parameter in PHP?

Posted: Sun Jan 11, 2004 11:14 pm
by shaky
in the C soure code, it use pointing parameter. Do PHP have a way to point to a parameter as well, to send the data in function.

Posted: Mon Jan 12, 2004 7:53 am
by Pyrite
Not sure what you mean? Do you mean using references?

Posted: Tue Jan 13, 2004 10:35 pm
by shaky
i mean parsing parameter as pointer(in C)

ex:

void print_field( string, x)
char *string;
FIELD2N *x;
{
INDEX i;

printf("%s\n",string);
SUMLOOP(i) printf("%8x ",x->e);
printf("\n");
}

parameter string is pointer.

And do php have function like Struct in C.

Posted: Wed Jan 14, 2004 9:27 am
by Pyrite
& is the php syntax for references - passing in by reference is
the equivalent of passing a pointer in c, although they are not
the same as pointers. Check the php manual on using references.

Posted: Wed Jan 14, 2004 9:32 am
by Pyrite
Oh, and PHP supports Class, which can be used just like a Struct.