How to write a basic encryption and pass it to the client?

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
Aric_Holland
Forum Newbie
Posts: 5
Joined: Sat Aug 09, 2008 6:23 pm
Location: Maui, HI

How to write a basic encryption and pass it to the client?

Post by Aric_Holland »

Hi,

I've been curious about encryption, and how to apply that to PHP.

Well, basically what I want to do is have client data such as a variable get sent to my xml-rpc server. I want the server to decrypt the data.

How would i go upon doing this?

Heres how the client code works:

<?php
$data = xu_rpc_http_concise(
array(
'method' => "server_version",
'host' => $host,
'uri' => $uri,
'port' => 80
)
);

function decrypt_data($param) {
// decrypt the data string...
}

print "Decrypted Data: $data";

?>
Ok heres the server code:

function server_version($method_name,$params,$app_data)
{
// now lets just say this string is encrypted.... - but its not!
$encrypted = "2342384928ejfkjsd";
return $encrypted;
}


So how would I go upon doing this? can you provide me a basic encryption code that will be able to have the server data encrypt and then be decrypted on the client side?


Much Appreciated,

Aric Holland
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How to write a basic encryption and pass it to the client?

Post by alex.barylski »

1. Secret key encryption
2. Public key encryption

SSL, Blowfish are two keywords for you to Google.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: How to write a basic encryption and pass it to the client?

Post by Apollo »

PHP contains builtin functions for encryption and decription: mcrypt_encrypt and mcrypt_decrypt
Post Reply