Encryption using C language in PHP environment?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

Encryption using C language in PHP environment?

Post 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 :)
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

Pointing parameter in PHP?

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Not sure what you mean? Do you mean using references?
shaky
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 2:06 am

Post 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.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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.
Last edited by Pyrite on Wed Jan 14, 2004 9:36 am, edited 1 time in total.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Oh, and PHP supports Class, which can be used just like a Struct.
Post Reply