Encryption/Decryption

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
Fly
Forum Newbie
Posts: 2
Joined: Thu Mar 06, 2003 5:54 pm

Encryption/Decryption

Post by Fly »

Hi there
This is the first time I have posted here and not sure if this is the best forum for this question but I'll try this room anyway so here it goes.

I am trying to write a public key encryption system based on the RSA Algorithm and have read lots of resources on the matter. I have however not an expert at PHP and so finding it hard to translate some of what I have read into php code.

What I am looking for is either a link or reply to this that can tell me how I can create the 3 values needed

n, e and d

where I need to create large prime numbers.

If anyone has information on creating large prime numbers and/or checking a value is a prime number whcih after reading information on the maths for this still has me confused that would be a great help or if anyone has the code or a link to source code for the RSA Algorithm I would very much appreciate it.

NOTE - I do not want to use extra moduals for this

Thanks

Fly


PS: why do I want this ?
I intend on combing this with javascript to let users send secure information when SSL is not avaliable.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

You said you were new to php so you might not have found the manual; if not, check out php.net for a full explanation of all the php functions.

Sorry, don't know enough to help you directly.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Have you checked out PHP's own encryption and decryption-function? I am no expert by far, but the existing PHP-functions more, much more than cover my needs.

Have a look at:

http://www.php.net/manual/en/function.md5.php

http://www.php.net/manual-lookup.php?pa ... on&lang=en
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Are you sure you want to do it in PHP? For public key encryption it is very common to use GnuPG, which exists on virtually all *nix machines, and is easy to install on a win machine, http://www.gnupg.org , access from php with a shell call
Fly
Forum Newbie
Posts: 2
Joined: Thu Mar 06, 2003 5:54 pm

Post by Fly »

Yer - I want to write my own script as best as possible and when I said I was new I still have a good understanding of much of php just not used some specific functions yet.

And thanks so far


Fly
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

..i am no mathematic nor cryptolic expert, but i am pretty sure that using PHP native math functions to create a fully functional RSA or simiar algorithm, it will be very slow and inefficient.. howver, using modules that are ment for such and/or your own compiled (C etc) programs or freely available ones it will execute a lot faster.. It is truly amazing how good and fast gnupg and openssl is at doing such..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but if he(?) wants to, why not? ;)
Post Reply