setKeyLength(128); $cipher->setKey($key); $cipher->setIV($key); $cipheredPass = $cipher->encrypt($password); // Mcrypt call left for documentation purposes - broken, see https://bugs.php.net/bug.php?id=51146 //$cipheredPass = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $password, MCRYPT_MODE_CFB, $key); // Following lines present for debug purposes only /* $arr = preg_split('//', $cipheredPass, -1, PREG_SPLIT_NO_EMPTY); foreach ($arr as $char) { error_log(ord($char)); } */ // Change to base64 to avoid communication alteration $passCrypted = base64_encode($cipheredPass); // The call to the webservice will change depending on your definition try { $response = $client->validateUser( [ 'user' => $username, 'pass' => $passCrypted, 'system' => 'chamilo', ] ); } catch (SoapFault $fault) { error_log('Caught something'); if ($fault->faultstring != 'Could not connect to host') { error_log('Not a connection problem'); throw $fault; } else { error_log('Could not connect to WS host'); } return 0; } return $response->validateUserResult; }