Java - php

Hi
Can I ask what's wrong with the following code?
I got 2 area in a html page, I want to press a button, then it will pass some information to area 2 which is the php script to manipulate.
public void actionPerformed(ActionEvent e) {
     AppletContext ac = getAppletContext();
     try{
     URL theURL = new URL("area2.php?state=TAS");
     ac.showDocument(theURL, "area2");
     }catch(MalformedURLException me){}
}

Nice catch block there. Do nothing if an error
occurs - that's great thinking.
In general that's true of course... well, it's
entirely untrue but you know what I mean ;o) ...but
surely in the situation where you're passing a
literal which you know absolutely to be a valid
parameter, there's no real need to implement any
useful handling.Maybe someone might try to hack the bytecode...

Similar Messages

  • Java+php+linuxruntime  error

    Dear all i have one java class i amm using php pages to to use this class
    currently i am getting below error
    Fatal error: Uncaught exception 'java_RuntimeException' with message 'Could
    not connect to the context server . Error message: Connection refused (111)
    ' in /usr/local/apache2/htdocs/java/Java.inc:1163 Stack trace: #0
    /usr/local/apache2/htdocs/java/Java.inc(1180):
    java_Protocol->createSimpleHandler('@java-bridge-10...') #1
    /usr/local/apache2/htdocs/java/Java.inc(1187):
    java_Protocol->createHandler() #2
    /usr/local/apache2/htdocs/java/Java.inc(365):
    java_Protocol->java_Protocol(Object(java_Client)) #3
    /usr/local/apache2/htdocs/java/Java.inc(1541): java_Client->java_Client() #4
    /usr/local/apache2/htdocs/java/Java.inc(1650):
    __javaproxy_Client_getClient() #5
    /usr/local/apache2/htdocs/java/Java.inc(1665): java_session_array(Array) #6
    /usr/local/apache2/htdocs/java.php(3): java_session() #7 {main} thrown in
    /usr/local/apache2/htdocs/java/Java.inc on line 1163

    "Connection refused"
    I think it is safe to assume your network settings are wrong and it actually has nothing to do with java. Firewall problem perhaps?

  • Java/php bridge

    Hi All,
    i am working on jdeveloper10.1.3 & OracleApps Server.
    suggests some possible ways to bridge Java/PHP?
    I am facing problem integrating with jsp page and php page . if any one know its great help me.
    What are the software’s required for bridge between java and php.
    Request is so needful.
    thq,
    elisha.

    Judging by your later response, I'd say Gene got it right first time in that it is a memory issue.
    It looks like your application needs more than 512m heap size. I guess there isn't enough on the box where WebLogic is installed, otherwise you would have used the same sizes as TomCat.
    Apologies if I'm stating the obvious

  • Issue with Java - PHP interoperability

    Hi,
    There are some converts written in PHP that can take raw wikipedia data and output a good HTML. I wanted to make use of these in my Java code.
    So in my Java Web App, I wanted to run the PHP parser, get hold of the InputStream and push it to my ServletOutputStream.
    Code Snippet:
       String command="php testparser.php Anarchism.wikimarkup";
       proc = Runtime.getRuntime().exec(command);
       InputStream in = proc.getInputStream();
       InputStreamReader isr = new InputStreamReader(in);
       BufferedReader br = new BufferedReader(isr);
       String line = null;
       while ((line = br.readLine()) != null) {
         System.out.println(line);
       }But the problem here is that the PHP Process never stops and hence the Buffer never ends. THe program is waiting in infinite loop in readLine().
    Please let me know if anyone has tried this and whats a better way to handle interoperability between PHP and Java.
    Thanks,
    Phani

    Phanikumar_Bhamidipati wrote:
    Yeah, I had a look at the document. But as per my understanding, the way the PHP engine runs is different from normal execs. I don't see how it can 'run different' and in my experience it doesn't. PHP sends output to stdout and stderr and reads from stdin. When PHP terminates it will close stdout and stderr and, if you have followed the recommendations in the reference, your readLine() will return 'null'.
    Because the same code ran fine when I automated unzipping a set of files using "bunzip2" command.If you read the article it explains a possible reason for this BUT until you implement the recommendations you will not know what is wrong.
    >
    I tried using Process.waitFor() method as well, but the result is same (Infinite Loop).This almost certainly is nothing to do with Process.waitFor() and probably everything to do with buffers filling (probably stderr).
    Until you post the code with the recommendations implemented that exhibits the same blocking problem it is a waste of time anyone responding further.

  • Authentification with Java, PHP, .htaccess

    Hi there,
    I am thinking about creating a Java project that requires some authentification routines.
    Users (which are given a unique user ID) are employing a client software (Java) that retrieves specific data from a webserver (available ressources HTML, SSI, PHP, .htaccess).
    A user should be able to use any client to get his data from the webserver, so unique client IDs are a non-option. Probably two users might even use two instances of the same client on the same machine (means, same IP).
    I want this to be reasonably secure, so no plaintext protocol. I thought about something like a challenge - response architecture, BUT...
    ...how can I do this with only PHP (server) and Java (client) as options?
    I don�t need a polished, smooth, perfect solution - a rough idea will do. Are there any secret / public key architectures with ready-to-use PHP modules that are also implemented in Java? Or has anybody a completely different idea I haven�t thought about yet?

    Have a look on RFC 2617 from IETF (www.ietf.org). This RFC specifies two mechanisms for authenticated access to HTTP resources. .htaccess is based on these mechanisms. Unfurtonately, they are not secure enough. The first protocol, BASIC, sends clear text username/password. The second, DIGEST, sends digests of the username/password using a challenge-response scheme. The disadvantage of DIGEST is that the username/password needs to be stored in clear on the server-side.
    What you could do, which is something I am currently working on myself, is to implement your own protocol, based on this RFC. This is possible because you are in control of both the clients and the server. It wouldn't be possible if standard browsers where used as clients.
    Good luck!
    /Christer

  • Java - PHP communication

    Hi,
    I'm quite new to EJB3 and going to build web application using (probably) EJB3 and Struts 2. My problem is, that I need to bound some parts of my new business logic with this older PHP website. I just need to call some simple Java methods (e.g. searching in db - pass on one or two parameters and get a result) from this PHP website. I've done some research and it looks like I should use Web services. There is a lot of materials for this topic in the web, but somewhere I've read, that web services are overkill for such the simple scenario. Is here any easier way to call Java business logic from PHP. Thank you very much for your answer.
    Edited by: esembaJ on 13.10.2008 22:53

    As I understood, your "application" consists of two parts: web site written on php and EJB+Struts.
    If so, you can easily make HTTP requests from php to your Struts actions.
    Your actions can make response in JSON (JavaScript Object Notation) with the help of json-plugin.
    With these approach you beat two things: you can make actions which can be easily used asynchronously (JSON helps to do this) also they can be used by any application that can parse JSON response.
    You don't need to dig into WS. Your case is very simple because of powerful java web-framework. WS will make your solution too complicated. Also you'll have troubles with WS on php-side.
    Once, I've had to send some data to java-WS from php4. I've tried to realize it in many ways, but finally I've made simple HTTP request with manually formed XML-body (it was SOAP).

  • SOAP - Java & PHP

    Hi all!
    I am developing now a SOAP extension for my web. I am using nusoap.php for PHP. Now I have the WSDL file and would like to connect to the server with Java. With WSDL2JAVA I create the Java Classes, but I could't connect to the server. Can anyone post me a link for more information about this?
    Thanks!
    Regards
    Nikolay

    how did you solve this? I am having a similar problem :(

  • Java - php / passing parameters

    hi,
    i am trying to set up a communication between my java app and a php skrip. i've done the following:
    try {
    URL url =
    new URL("http://test.net/" +
    "login.php");
    URLConnection connection =
    url.openConnection();
    connection.setDoOutput(true);
    PrintStream out =
    new PrintStream(connection.getOutputStream());
    out.println("username=" + URLEncoder.encode("test"));
    out.println("password=" + URLEncoder.encode("9e07480f0e4952926e115f15bc50ec47"));
    out.close();
    DataInputStream in =
    new DataInputStream(connection.getInputStream());
    result = in.readLine();
    System.out.println("result:" + result.toString());
    in.close();
    } catch(MalformedURLException mue) {
    System.out.println("Illegal URL: " + mue);
    } catch(IOException ioe) {
    System.out.println("IOException: " + ioe);
    } catch(Exception e) {
    System.out.println("Error: " + e);
    the php gets my request but it doesn't realize the parameters username/passord.
    is there a way to set the parameters through the api or do is the only way to do it by adding them to the url like ?username=bla&password=bla. i really would like to do it on a higher level but maybe there is no api support available. thanx for any advice, mischka.

    Golden rule of testing: test one thing at a time.
    Try it with this (working code) to test that you know that you CAN write a simple *.txt message file from a TextField first before extending it to verification /password whatever conditions.import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    public class write extends java.applet.Applet implements ActionListener {  
        TextArea info = new TextArea(10,60);
         Button Bsend = new Button("SEND");
         String str = "", text="";
         public void init() {
              add(info);
              Bsend.addActionListener(this);
              add(Bsend); 
         public void paint (Graphics g) {
              g.drawString(str, 30, 270);
         public void actionPerformed(ActionEvent evt) {
                if (evt.getSource().equals(Bsend) ) {
                try{
                    writePage();
                   catch(Exception x){ System.out.print(x); }
              repaint();
        public void writePage() throws Exception {  
            text = info.getText();     
             URL url = new URL("http://"+getCodeBase().getHost()+"login.php");
                URLConnection conn = url.openConnection();
                conn.setDoOutput(true);
                OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                wr.write(text);
                wr.flush();
            wr.close();
            str = "Information sent to " + getCodeBase().getHost().toString();
    }

  • Web hosting for ColdFusion, ROR, Java, PHP, MySQL

    The company I currently use to host my web site supports PHP, MySQL, Ruby on Rails, but I don't think it supports ColdFusion, and I would imagine there are other things I could not put on my web site, such as EJB based Java apps.
    My point is that does anyone know of a web hosting company that supports PHP, MySQL, Ruby on Rails, AND ColdFusion, AND anything else I might need to be able to practice using Flex to connect to data on the server using various technologies, like RemoteObject, WebService, etc.
    The web hosting company must be reliable and stable as well.

    I'd recommend you to get a dedicated server and setup there everything you need.
    http://0x2a-dc.com/index.php?name=shop&cat=7

  • Array_reverse() in PHP -- ist it possible in JAVA?

    Hello JAVA Community,
    I'am a newbe in JAVA, an older C++/PHP Developer.
    How can I do that in JAVA:
    // PHP Code:
    $input  = array(3,4,6,6,7,8,9);
    $result = array_reverse($input);thank you very much for your kind solutions..
    rgds emile

    >
    Dear Aurelius,
    thank very much but im am just looking of an "method", ist there any method or not? That is my question.There is not one built in by default, but I showed you both how to do it and how to make it specially built into the system for you.
    Emil_Orlowski wrote:
    An older C++ developer, you say? I don't mean to be condescending, but you never had to do anything like
    this in C++? The C++ I know is the land of "You have to do everything yourself."Please do not be angry with me! I have difficulties to comprehend it, why one is busy with unnecessary details? It is just about a PHP function; I search for an equal function in Java.The answer simply could be "there is nothing something like that in Java".Do not worry; I am not angry with you.
    I see that you have difficulty comprehending it, as you say. Based on your writing, it appears that English is not your first language. Is that correct? I did not realise this at first. I will assume any misunderstanding is due to this language barrier.
    >
    It is just about a PHP function; I search for an equal function in Java.The answer simply could be "there is nothing something like that in Java".
    >
    Someone else has pointed out that it does exist in Java, though it is for a different data structure and not specifically for an array.
    You can put what I gave you into a method and call that, or you can use a Collection instead of an array and use the Collections reversal method that someone else mentioned.
    One last thing, concerning terminology, just in case you did not realise it (I assume not since you write "method" in quotation marks) since you are used to dealing with C++ and PHP. The term method refers to a function which is a member of a class or object, and, since almost all data are objects in Java, all functions in Java are methods. Everyone around here will say method instead of function.
    I hope all this helps you. Good fortune to you in your Java endeavors.

  • Missing fonts in Java

    Reformated my XP SP3 computer and loaded Firefox 13.0.1 and Java from Oracle.
    When I open any pages that have javascripted close X's on them I receive a square box with 27 over 16 in it instead of the X.
    On one site the code reads:
    font-family: "Helvetica Neue",Helvetica,Arial,Verdana,sans-serif;
    <a href="javascript:return void(0);">✖</a>
    (Not sure if that will show up at your end as a little box - or - a little box with the 27 and 16 in it).
    I checked http://browserspy.dk and got a list of 45 fonts on Fonts Information - Detected via Flash (http://browserspy.dk/fonts-flash.php) but
    only 36 on Fonts Information - Detected via Java (http://browserspy.dk/fonts-java.php)
    Helvetica is missing from both lists.
    These fonts are showing up on the Java page but not the Flash page.
    Dialog
    DialogInput
    Lucida Sans
    Monospaced
    SansSerif
    Serif
    These fonts are showing up on the Flash page but not the Java page.
    Arial Baltic
    Arial CE
    Arial CYR
    Arial Greek
    Arial TUR
    Courier New Baltic
    Courier New CE
    Courier New CYR
    Courier New Greek
    Courier New TUR
    Times New Roman Baltic
    Times New Roman CE
    Times New Roman CYR
    Times New Roman Greek
    Times New Roman TUR
    Really not sure what to do about this.
    Is there someway I can get Flash/Java to recognise these fonts?
    Thank You

    That is an Unicode symbol &amp;#x2716;
    If you see the hex code instead of the character then Firefox wasn't able to find a (dingbat) font that handles this character.
    *http://www.alanwood.net/unicode/dingbats.html

  • How Can i use the key file Generated by RSACryptoServiceProvider to encrypt with php?

    I need to be able to encrypt data in PHP using a public key generate by .NET(RSACryptoServiceProvider).  I will then decrypt the data later in C# using the private key.
    Code Snippet
    <RSAKeyValue><Modulus>xU5JyaPNDKXI/h/uo5Vk89wZSz3zsB1+c+1IMYIQa+mCmuRCRPuoBI7ODSV2ndP6grfhdrWEzhpZtkI3SThbBh/3t+tfZ2PF8Iyv9ECN07V64nPCiJGhAnfENE+J9UD9Kw5czXHgZcBbpM5N0VfXmLSleaS65DDoNPtoStVy7ss=</Modulus><Exponent>AQAB</Exponent><P>4ScAjVrPZii/6lICAP2yDQiNEmNL74+5AcxNVDI0IombfDPIygrqEWmuDu0pngApQak7XnEnLbaDChILFiHPZQ==</P><Q>4FaYlse+cjrlPD/jk+GsTJeuP7yuQx8ztjVnQWVh6GKQP+uk1dAl6kcZOfLNR6LWwE3CSygt8PthTEw96Zbabw==</Q><DP>XvXtNLE9UjATqYeHEtXtV7Pok/3PVC3A8PIzFzTJaluxeXP51sU9rbRt1hvO9rXIsMnooU+GH7Cfmgq8JEyERQ==</DP><DQ>HXkC/vwq9xLpvuqd2XXSjxV2XQVK16Knxo5pjFvnawJX9S3eMADymj7Q/534firUj9snZXxX3MsJ015I3AFnnQ==</DQ><InverseQ>AM0fVCE3n2FKf2zb3CcDEge1Ko35VvMEL+LXgR87QwO2HScZSuLevGLi2SSAkB1vu8RSNzB028SZReeOZWnq4Q==</InverseQ><D>fI+GKdRNOTTYhQZnw8Im74T+OvArjf2wvUMJlqfD8jyDBYIhDCfL1MTK9KW4Er+moSuxHR5Pb0ZXaKa4/HKlk0aJ1jB2C+jg7zTSuPRNuS16BpVHaJYsQurCwZwElXMum+GxeXK/h3wXWq5HwebjqZr0aLUMZKRcweDPRoVFiRE=</D></RSAKeyValue>
    As you see this code snippet is a xml format private key. at .net platform,which can use encrypt or dencrypt.
    i have try the Extension Crypt RSA ( http://pear.php.net/reference/Crypt_RSA-1.0.0/elementindex_Crypt_RSA.html ) to help me encrypt data by php.but it haven't return a currect result. the data encrypted by php cann't dencrypt by c#.
    does the RSA algorithm provider by Crypt_RSA can give a stand result as c#?
    BTW :i just use the xmlkeystring like this.
    Code Snippet
    <?php
    require_once("Crypt/RSA.php");
    require_once("includes/Utils.class.php");
        $public_key_string = simplexml_load_string("<RSAKeyValue><Modulus>xU5JyaPNDKXI/h/uo5Vk89wZSz3zsB1+c+1IMYIQa+mCmuRCRPuoBI7ODSV2ndP6grfhdrWEzhpZtkI3SThbBh/3t+tfZ2PF8Iyv9ECN07V64nPCiJGhAnfENE+J9UD9Kw5czXHgZcBbpM5N0VfXmLSleaS65DDoNPtoStVy7ss=</Modulus><Exponent>AQAB</Exponent><P>4ScAjVrPZii/6lICAP2yDQiNEmNL74+5AcxNVDI0IombfDPIygrqEWmuDu0pngApQak7XnEnLbaDChILFiHPZQ==</P><Q>4FaYlse+cjrlPD/jk+GsTJeuP7yuQx8ztjVnQWVh6GKQP+uk1dAl6kcZOfLNR6LWwE3CSygt8PthTEw96Zbabw==</Q><DP>XvXtNLE9UjATqYeHEtXtV7Pok/3PVC3A8PIzFzTJaluxeXP51sU9rbRt1hvO9rXIsMnooU+GH7Cfmgq8JEyERQ==</DP><DQ>HXkC/vwq9xLpvuqd2XXSjxV2XQVK16Knxo5pjFvnawJX9S3eMADymj7Q/534firUj9snZXxX3MsJ015I3AFnnQ==</DQ><InverseQ>AM0fVCE3n2FKf2zb3CcDEge1Ko35VvMEL+LXgR87QwO2HScZSuLevGLi2SSAkB1vu8RSNzB028SZReeOZWnq4Q==</InverseQ><D>fI+GKdRNOTTYhQZnw8Im74T+OvArjf2wvUMJlqfD8jyDBYIhDCfL1MTK9KW4Er+moSuxHR5Pb0ZXaKa4/HKlk0aJ1jB2C+jg7zTSuPRNuS16BpVHaJYsQurCwZwElXMum+GxeXK/h3wXWq5HwebjqZr0aLUMZKRcweDPRoVFiRE=</D></RSAKeyValue>");
        $key =new Crypt_RSA_Key(base64_decode($public_key_string->Modulus),base64_decode($public_key_string->Exponent),"public");
        echo "<pre>";
        print_r($key);
        echo "</pre>";
        $rsa_obj = new Crypt_RSA();
        //try encrypt data
        echo "encrypted result is:<br/>".$rsa_obj->encrypt("this is a smple text.",$key)
        ?>
    but the encrypted data cann't decrypt by c#?where is the problem?what should i do with php codes?

    thank you for your reply, i also found this article by google.but this does not meet scene,  thank you all the same.
    i have already solved the problem now,i'd like to post the Solution .infact it's so easy to use rsakey file generated by .net .
    -------------rsa.class.php-------------------
    Code Snippet
    <?php
     * Some constants
    define("BCCOMP_LARGER", 1);
    class RSA
      * PHP implementation of the RSA algorithm
      * (C) Copyright 2004 Edsko de Vries, Ireland
      * Licensed under the GNU Public License (GPL)
      * This implementation has been verified against [3]
      * (tested Java/PHP interoperability).
      * References:
      * [1] "Applied Cryptography", Bruce Schneier, John Wiley & Sons, 1996
      * [2] "Prime Number Hide-and-Seek", Brian Raiter, Muppetlabs (online)
      * [3] "The Bouncy Castle Crypto Package", Legion of the Bouncy Castle,
      *      (open source cryptography library for Java, online)
      * [4] "PKCS #1: RSA Encryption Standard", RSA Laboratories Technical Note,
      *      version 1.5, revised November 1, 1993
      * Functions that are meant to be used by the user of this PHP module.
      * Notes:
      * - $key and $modulus should be numbers in (decimal) string format
      * - $message is expected to be binary data
      * - $keylength should be a multiple of 8, and should be in bits
      * - For rsa_encrypt/rsa_sign, the length of $message should not exceed
      *   ($keylength / 8) - 11 (as mandated by [4]).
      * - rsa_encrypt and rsa_sign will automatically add padding to the message.
      *   For rsa_encrypt, this padding will consist of random values; for rsa_sign,
      *   padding will consist of the appropriate number of 0xFF values (see [4])
      * - rsa_decrypt and rsa_verify will automatically remove message padding.
      * - Blocks for decoding (rsa_decrypt, rsa_verify) should be exactly
      *   ($keylength / 8) bytes long.
      * - rsa_encrypt and rsa_verify expect a public key; rsa_decrypt and rsa_sign
      *   expect a private key.
      * rsa encrypt data
      * @param binary string $message
      * @param unknown_type $public_key
      * @param numbers $modulus
      * @param numbers $keylength
      * @return binary data
     function rsa_encrypt($message, $public_key, $modulus, $keylength)
      $padded = RSA::add_PKCS1_padding($message, true, $keylength / 8);
      $number = RSA::binary_to_number($padded);
      $encrypted = RSA::pow_mod($number, $public_key, $modulus);
      $result = RSA::number_to_binary($encrypted, $keylength / 8);
      return $result;
     function rsa_decrypt($message, $private_key, $modulus, $keylength)
      $number = RSA::binary_to_number($message);
      $decrypted = RSA::pow_mod($number, $private_key, $modulus);
      $result = RSA::number_to_binary($decrypted, $keylength / 8);
      return RSA::remove_PKCS1_padding($result, $keylength / 8);
     function rsa_sign($message, $private_key, $modulus, $keylength)
      $padded = RSA::add_PKCS1_padding($message, false, $keylength / 8);
      $number = RSA::binary_to_number($padded);
      $signed = RSA::pow_mod($number, $private_key, $modulus);
      $result = RSA::number_to_binary($signed, $keylength / 8);
      return $result;
     function rsa_verify($message, $public_key, $modulus, $keylength)
      return RSA::rsa_decrypt($message, $public_key, $modulus, $keylength);
     function rsa_kyp_verify($message, $public_key, $modulus, $keylength)
      $number = RSA::binary_to_number($message);
      $decrypted = RSA::pow_mod($number, $public_key, $modulus);
      $result = RSA::number_to_binary($decrypted, $keylength / 8);
      return RSA::remove_KYP_padding($result, $keylength / 8);
      * The actual implementation.
      * Requires BCMath support in PHP (compile with --enable-bcmath)
     // Calculate (p ^ q) mod r
     // We need some trickery to [2]:
     //   (a) Avoid calculating (p ^ q) before (p ^ q) mod r, because for typical RSA
     //       applications, (p ^ q) is going to be _WAY_ too large.
     //       (I mean, __WAY__ too large - won't fit in your computer's memory.)
     //   (b) Still be reasonably efficient.
     // We assume p, q and r are all positive, and that r is non-zero.
     // Note that the more simple algorithm of multiplying $p by itself $q times, and
     // applying "mod $r" at every step is also valid, but is O($q), whereas this
     // algorithm is O(log $q). Big difference.
     // As far as I can see, the algorithm I use is optimal; there is no redundancy
     // in the calculation of the partial results.
     function pow_mod($p, $q, $r)
      // Extract powers of 2 from $q
      $factors = array();
      $div = $q;
      $power_of_two = 0;
      while(bccomp($div, "0") == BCCOMP_LARGER)
       $rem = bcmod($div, 2);
       $div = bcdiv($div, 2);
       if($rem) array_push($factors, $power_of_two);
       $power_of_two++;
      // Calculate partial results for each factor, using each partial result as a
      // starting point for the next. This depends of the factors of two being
      // generated in increasing order.
      $partial_results = array();
      $part_res = $p;
      $idx = 0;
      foreach($factors as $factor)
       while($idx < $factor)
        $part_res = bcpow($part_res, "2");
        $part_res = bcmod($part_res, $r);
        $idx++;
       array_push($partial_results, $part_res);
      // Calculate final result
      $result = "1";
      foreach($partial_results as $part_res)
       $result = bcmul($result, $part_res);
       $result = bcmod($result, $r);
      return $result;
     // Function to add padding to a decrypted string
     // We need to know if this is a private or a public key operation [4]
     function add_PKCS1_padding($data, $isPublicKey, $blocksize)
      $pad_length = $blocksize - 3 - strlen($data);
      if($isPublicKey)
       $block_type = "\x02";
       $padding = "";
       for($i = 0; $i < $pad_length; $i++)
        $rnd = mt_rand(1, 255);
        $padding .= chr($rnd);
      else
       $block_type = "\x01";
       $padding = str_repeat("\xFF", $pad_length);
      return "\x00" . $block_type . $padding . "\x00" . $data;
     // Remove padding from a decrypted string
     // See [4] for more details.
     function remove_PKCS1_padding($data, $blocksize)
      assert(strlen($data) == $blocksize);
      $data = substr($data, 1);
      // We cannot deal with block type 0
      if($data{0} == '\0')
      die("Block type 0 not implemented.");
      // Then the block type must be 1 or 2
      assert(($data{0} == "\x01") || ($data{0} == "\x02"));
      // Remove the padding
      $offset = strpos($data, "\0", 1);
      return substr($data, $offset + 1);
     // Remove "kyp" padding
     // (Non standard)
     function remove_KYP_padding($data, $blocksize)
      assert(strlen($data) == $blocksize);
      $offset = strpos($data, "\0");
      return substr($data, 0, $offset);
     // Convert binary data to a decimal number
     function binary_to_number($data)
      $base = "256";
      $radix = "1";
      $result = "0";
      for($i = strlen($data) - 1; $i >= 0; $i--)
       $digit = ord($data{$i});
       $part_res = bcmul($digit, $radix);
       $result = bcadd($result, $part_res);
       $radix = bcmul($radix, $base);
      return $result;
     // Convert a number back into binary form
     function number_to_binary($number, $blocksize)
      $base = "256";
      $result = "";
      $div = $number;
      while($div > 0)
       $mod = bcmod($div, $base);
       $div = bcdiv($div, $base);
       $result = chr($mod) . $result;
      return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT);
    ?>
    -------------RSAProcessor.class.php------------------------
    Code Snippet
    <?php
    require_once("rsa.class.php");
    class RSAProcessor
     private $public_key = null;
     private $private_key = null;
     private $modulus = null;
     private $key_length = "1024";
     public function __construct($xmlRsakey=null,$type=null)
             $xmlObj = null;
       if($xmlRsakey==null)
               $xmlObj = simplexml_load_file("xmlfile/RSAKey.xml");
              elseif($type==RSAKeyType::XMLFile)
               $xmlObj = simplexml_load_file($xmlRsakey);
              else
               $xmlObj = simplexml_load_string($xmlRsakey);
             $this->modulus = RSA::binary_to_number(base64_decode($xmlObj->Modulus));
       $this->public_key = RSA::binary_to_number(base64_decode($xmlObj->Exponent));
       $this->key_length = strlen(base64_decode($xmlObj->Modulus))*8;
      * get public key
      * @return string public key
     public function getPublicKey()
      //return base64_encode(RSA::number_to_binary($this->public_key,($this->key_length)/8));
      return $this->public_key;
     public function getPrivateKey()
      //return base64_encode(RSA::number_to_binary($this->private_key,($this->key_length)/8));
      return $this->private_key;
     public function getKeyLength()
      return $this->key_length;
     public function getModulus()
      return $this->modulus;
      * encrypt data
      * @param string $data
      * @return base64 encoded  binary string
     public function encrypt($data)
      return base64_encode(RSA::rsa_encrypt($data,$this->public_key,$this->modulus,$this->key_length));
     public function dencrypt($data)
      return RSA::rsa_decrypt($data,$this->private_key,$this->modulus,$this->key_length);
     public function sign($data)
      return RSA::rsa_sign($data,$this->private_key,$this->modulus,$this->key_length);
     public function verify($data)
      return RSA::rsa_verify($data,$this->public_key,$this->modulus,$this->key_length);
    class RSAKeyType
     const XMLFile = 0;
     const XMLString = 1;
    ?>
    -------------- encrypt data with public key-----------------
    Code Snippet
    <?php
    require_once("RSAProcessor.class.php");
    $processor = new RSAProcessor
    ("<RSAKeyValue><Modulus>m6ljoeWhmnd0oRnsVEH5iNw3B8+vKVu7v7CVfMyf6bnKEzHa62TRmT/baJiSevoI/vgm2ph/s1JrQQTaGiErHicigwSC
    Aw7+i05WFbnz7tOyiiJJVMfsdd+v7Xan9Hiud05FzxoMbM8vpiMHPEIDbGJ1MiXyupTVkz2WcMHyBoJ4S189opktZ43pviUhy0PeuWkyoU7zR54akPmK
    Yg+z5Zr1r7K8lUZ1a3TThfJGxTQR/uZMtZz/q8QF0AANVQ/eyahTv9icBzBoDuncS0Y5l3vqogW1C/ltJvhJpvSn/OgjbRjuixCAptOUmRd13sDWU95/
    x0bMq+Lg68lj2OjJ1Q==</Modulus><Exponent>AQAB</Exponent><P>zfvdBsMLlmo+4PAUYLgSV2xyyVa7ZqFjkJaAE4EbYuH24EoZjrzeiJR++D
    FUT/GUhjfZ5eZ/5e29dXwk0sKUw6nHzBdBtOPp5fr4t5SKLEcWY+J+zLUSOlhG9NUkohFf6+Miy2Y7BLpXVrcl6UwXV0ak8KkTPB2l/aIMwYj5dgc=</
    P><Q>wXV0sA3nDzoSDQA/4QSu/WIlBhkA3jZ7K7G9Z9rpP1A0vH+bZeyCIyo52u8ahGuYbubaizF1XMp+Xv3Mh2KmRbt7+UptwEwbFAUiiad2a312mqm
    j7IJd7gRjGkyzKEm+6fpNeY3NFLNVNhccBqzhNkRoM22xnvQcImD10XVAakM=</Q><DP>wd1HdCLEWCfc0DYE59a2pINUMXyo2foRTDbpifHcRZ+ojAY
    Rsc6+nsssCQnccXVMNVqBgSgEvfGYe+eAfMBX5SN5APPuioJrVGF2DsoFlZC+WPoGH0JYSoNlHO8yEDrMDaXzzH2GFHgQ1XOAged0nFbHzB1FFjJNVL5
    cxRXWu6c=</DP><DQ>QDKuCk5SwubOXqoaiJ15RHRxPNjHRPZnYVSWOgSXKn9/QJ5H/0bA2NKGaHS4JAFgkEzjcRV0kNpRnUwztymxa6qPtWZRjWK0Ca
    y6jVuZHIqB9UkeMLoCWZ3zFSMmwNPYGuUJGLFJwPjR6iU5E64C/nMs8QQR0WHIhFAQwvVZ7uk=</DQ><InverseQ>JckMSlJR10VZdnp83VPjrZ/Z+63
    CGu3tWHm7f4DJ8IwjJWr8FlCpbSwiP6a4e9Upv6bUn/tOj2gY6MMq5G5yTKm2SCRvpUKRu4NCmWAt7vlFv0Z6pkXlTOpzvVjv3v16+dIZOA5Zn+v7+r1
    xbdYdH20KRAbiBO3MfQP7s+VJJvM=</InverseQ><D>W1xrBr2hQOj1wgxWAgoK7IHbprEFrK+TnWmGA46SGPsbmHJ9fAVbY6fwHg7Wgmk4WHXLUCeLY
    /Nu0eWIISfwh60Oe3ls2WC2k4qxyeSvQDBuLNb81U7WAUT9m9E1uK4QMCP3oxs1ybM80zTh7UMNgVK0WG+fbFUomVffcWTTqW+Fu12PEIO+UR/85oq+x
    qVlTzYAEzt1OE9IhkYiRzi99ePXeH2gFltzJ/fb/7jLsDTkhM2eiYTGyOTZmBnen6c6a8b9LFTY4Bc0bGpk5ezHkub6F8p2ZgL/JgIOJMyRZICjDjs+9
    k9PTmMTFsCF6xzHY15Fg25xIDYzIyx1rrRUjQ==</D></RSAKeyValue>",RSAKeyType::XMLString);
    $rs =  $processor->encrypt("Hello,It's Works.");
    echo $rs;
    ?>
    with the front codes.you can easy to encrypt data by public key generate by .net programe.

  • Java won't work on Firefox, while it works on Safari on a Mac.

    I have a MacBook Pro and downloaded Firefox 3.6 for it. Now I've realized that Java plugins won't work in Firefox for some reason, while they do work in Safari that came with the Mac. The problem wouldn't be with Java, since it works on Safari.
    The Java-related plug-ins I have installed in Firefox are the Java Embedding Plug-in 0.9.7.3 and Java Plug-in 2 for NPAPI browsers.
    When I go to a page that contains a Java applet, there is no error, the page says it's done loading, and there's a blank spot where an applet is supposed to be.

    Actually, I have both plugins installed in Mac OS X 10.6, verified by entering '''about:plugins''' in the SeaMonkey 2 Location Bar (address bar)
    Java Embedding Plugin 0.9.7.3
    <br>File name: MRJPlugin.plugin
    Java Plug-In 2 for NPAPI Browsers
    <br>File name: JavaPlugin2_NPAPI.plugin
    This is a new iMac computer I just set up last week running OS X 10.6.4 with all current Apple Software Updates. I have SeaMonkey 2 installed on it, but not Firefox.
    I have Java 6 Update 20 ( 1.6.0_20 ) installed, verified by going to the test link in the KB article I posted above,
    http://javatester.org/version.html
    Java 1.6.0_20 (referred to as "Java for Mac OS X 10.6 Update 2" on the page cor-el linked) should be available from Apple's [http://support.apple.com/kb/HT1338 Software Update] feature.
    Another test link you can try (from about:plugins):
    http://browserspy.dk/java.php
    I think that the Java Embedding plugin is something that Mozilla includes with all its current browsers (Firefox, SeaMonkey, Camino) based on: http://plugindoc.mozdev.org/OSX.html#Java
    ...which links to http://javaplugin.sourceforge.net/

  • Java was blocked due to the threat I have followed the update & other options to reenable it ie.manual updates reinstalls yet websites like YouTube still wont load up.Works fine in Chrome & IE!

    Java was blocked due to the threat I have followed the update & other options to reenable it ie.manual updates reinstalls yet websites like YouTube still wont load up.Works fine in Chrome & IE!

    Your plugins list in "more system details" shows Next Generation Java Plug-in 1.6.0_31 for Mozilla browsers so Java should not be blocked.
    Could you post a link to a webpage where Java isn't working for you? YouTube uses Flash, not Java. Here is a list of Java test pages you can try, to confirm that Java is working, from http://kb.mozillazine.org/Java#Testing_Java
    * [http://www.java.com/en/download/help/testvm.jsp Test your Java Virtual Machine (JVM)] at java.com.
    * [http://browserspy.dk/java.php Java Information - BrowserSpy.dk]
    * [http://javatester.org/ Java Tester] - The test pages at javatester.org will tell you if your web browser is enabled for Java and, if so, the Java version.
    * [http://www.pinlady.net/PluginDetect/Java/ Java Plugin Detector]
    By the way, I see in your plugins list that you also have the VLC media player Web Plugin 2.0.0 so, it's possible that the VLC plugin is causing a conflict if YouTube or other videos don't work. See [[Video or audio does not play]] (you may need to disable the VLC Media Player plugin in the Add-ons -> Plugins list for some media to play).

  • How to make sure an applet runs with Java 5?

    Hi all,
    First let me say thanks for all the help in the past. You've help me go from noob to intermediate noob. I've just about finished my first applet game which can be checked out here .
    Now I've been reading about problems with mac and 1.6. (note it works on Linux). I want to make sure that it runs fine and of course I don't own a mac. So I downloaded the 5 JDK. Selected it as the java platform in Netbeans, compiled and it ran fine.
    Questions:
    Do I have to always use 1.5 to compile and perhaps set it as default?
    Since it works in 1.5, do I compile it with 1.6 and just upload?
    I'm worried I'm not testing it correctly. I mean if I have both 1.5 and 1.6 installed on my machine, how to I make sure the applet is only using 1.5 to run?
    Thanks
    Darrin

    corlettk wrote:
    I haven't got a clue RE your problem other than for max-portability you should compile with [-target 1.5|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html].
    I must say I'm impressed, except I suspect my PC must be substantially faster than any of your test platforms... can you throttle it to CPU performance somehow? Or maybe it's just that my reflexes aren't what they once where.Thanks.
    There seem to be two issues. The first is what people are using. This web stats shows pretty poor penetration of 1.6.
    [http://www.statowl.com/java.php|http://www.statowl.com/java.php] Penetration: 54% with JRE1.6 + 19% with JRE 1.5. Total 73%.
    The second is I've read that mac and 1.6 do not get along except on a 64bit platform.
    So for applets there is not much choice but to compile on 1.5 for the broadest user base. I guess the good news is 1.4 and earlier are almost non-existent.
    Edited by: Darrin.A on Apr 27, 2009 8:11 AM

Maybe you are looking for