Encryption Types

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
milsaw
Forum Newbie
Posts: 1
Joined: Fri May 20, 2005 11:28 pm

Encryption Types

Post by milsaw »

Howdy folks,

I was wondering if PHP offered any sort of encyption that was different for each server.

So like on my server it could be like encrypt($string)...that equals jfdaso8u34wnfa8

While on my friends server if I did the same string so...encrypt($string)....his equals dfjasjfwo3ihfsna

I hope that makes sense, and thanks for your time

Also, I have PHP v4.2.

Thanks again
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

... what?
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

are you saying that you saved a variable on your server then went to his server and it was different? if this is the case ,that is because his server probably already has that variable saved as something else
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

PHP only offers encryptions that is built into its compiler (ie : crypt, md5, etc.). if you want to use a server-based encryption, you are going to need to check with that webserver's website and check with them..

but if ur question is if you use md5 on an apache server and then try to run the same code on an IIS server, and simply want to know if the values will change, then the answer is no. whatever the encryption string is created using an apacehe server is goign to be on an IIS server as the server isn't what is controlling your encryption, but php is. The server just says "ok, you send me a string, and I'll send it wherever you specify". again, that's unless the server has its own built in encryption method and you call that encryption via the server directly.

hope this helps.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Encryption Types

Post by Roja »

milsaw wrote: I was wondering if PHP offered any sort of encyption that was different for each server.
Yes and no.

Yes, there is an encryption that you can setup to be different per server - multiple types in fact.

What you are describing is essentially "Salting". If you do md5("whatever") on both servers, the answer will be consistent - the same.

However, by adding a unique "Salt", you can get different results from one machine to the other. So that:

md5("whatever" + $salt) (on server one)
md5("whatever" + $salt) (on server two)

would not be the same, as long as $salt was different between the two. For example, you could do:

$salt = $SERVER['SERVER_NAME'];

and of course it would be different on each.

However, to answer the original question, NO, there is not a type of encryption that automatically salts differently from one server to another, as far as I know.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

good call, i didn't even think of it that way...
Post Reply