From: <php...@li...> - 2007-04-27 15:38:09
|
Vielen Dank, Jost. This is very helpful :) This project is my introduction to Java, so I'm learning how to interpret its default and imported classes as I go along (and it's the concept of an interface that is throwing me for a loop at the moment, at least regarding how to represent this in php). Question: this doesn't seem to be a php construct to me: $algorithm.update($password->getBytes()); I will test what you sent to me below and attempt to reconstruct this, but I thought I'd pose the question here of what this means in php (specifically the period -- I understand this as a Java (and Javascript and vbscript, etc) construct rather than the typical -> in php). Thanks for your help, Kate -----Original Message----- From: php...@li... [mailto:php...@li...] On Behalf Of php...@li... Sent: Friday, April 27, 2007 2:36 AM To: php...@li... Subject: Re: [Php-java-bridge-users] PHP Java Translation Help Hi, > algorithm.update(password.getBytes()); > $str =3D new Java('java.lang.String'); > $algorithm->update($str->getBytes($password)); the above PHP code creates a zero-length String and then calls "".getBytes(<password>). The getBytes() function needs a symbol as its argument or no argument at all, not a password. :) Your Java code translated into PHP is: <?php require_once("http://localhost:8080/JavaBridge/java/Java.inc"); $password=3Dnew String("$passwd"); $algorithm=3Djava("java.security.MessageDigest")->getInstance(ENCRYPTION_= T YPE); $algorithm->reset(); $algorithm.update($password->getBytes()); $encrypted =3D $algorithm->digest(); $out =3D new java("java.io.ByteArrayOutputStream"); $encoder =3D java("javax.mail.internet.MimeUtility")->encode(out, ENCODING_TYPE); $encoder->write(encrypted); $encoder.flush(); return new String(out.toByteArray()); ?> (not tested) Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever ------------------------------------------------------------------------ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |