summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6221c8a)
raw | patch | inline | side by side (parent: 6221c8a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Nov 2007 13:02:32 +0000 (13:02 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Nov 2007 13:02:32 +0000 (13:02 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7956 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/socket_server/client.php | patch | blob | history | |
contrib/socket_server/server.php | patch | blob | history | |
include/class_socketClient.inc | patch | blob | history |
index c41f1d12b19c418a38a19a1fb630807cb7470802..97cd490a071e586ac0f6939c5cca2e3c83d19600 100755 (executable)
require_once("../../include/class_socketClient.inc");
error_reporting(E_ALL);
-
echo "\n\nTry to connect";
$sock = new Socket_Client("localhost","10000",TRUE,1);
$sock->SetEncryptionKey("Hallo hier bin ich.");
/* Prepare a hunge bunch of data to be send */
$data = "a";
- for($i = 0 ; $i < (100 * 1); $i++){
- $data .= "a";
+ for($i = 0 ; $i < (12 * 1); $i++){
+ $data .= "a\n";
}
echo "|--Sending ".strlen($data)."bytes of data to socket.\n";
$sock->send($data);
index 66663517aa9930adc259e0d83d510bcda893ad7f..bc65fab161d06b600c122daa0aa98f81b00851a3 100755 (executable)
if($enable_encryption){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = base64_encode(mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv));
+ $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
}
- return($data);
+ return(base64_encode($data));
}
function decrypt($data,$key)
{
global $enable_encryption;
+ $data = base64_decode($data);
+
/* Decrypt data */
if($enable_encryption){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv);
+ $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
+ $data = rtrim($data,"\x00");
}
return($data);
}
index 74066e4bb3bcdcd48cd7e118539ef3cdcce58c20..da54da5a8c298e1367ddf366e2daa74262182968 100755 (executable)
{
/* Encrypt data */
if($this->encrypt){
- $data = base64_encode(mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv));
+ $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv);
}
- return($data);
+ return(base64_encode($data));
}
private function decrypt($data)
{
+ $data = base64_decode($data);
/* decrypt data */
if($this->encrypt){
- $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, base64_decode($data), MCRYPT_MODE_ECB, $this->iv);
+ $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv);
+ $data = rtrim($data,"\x00");
}
return($data);
}
public function send($data)
{
if($this->handle){
- if($this->encrypt){
- $data = $this->encrypt($data);
- }
-
+ $data = $this->encrypt($data);
$data = trim($data);
fputs($this->handle,$data."\n");
$this->b_data_send = TRUE;
}
$this->bytes_read = strlen($str);
$this->b_data_send = FALSE;
- if($this->encrypt){
- $str = $this->decrypt($str);
- }
+ $str = $this->decrypt($str);
}
return($str);
}