Menu

[r1106]: / branches / Release-6-0-4 / php-java-bridge / tests.php5 / encryptPassword.php  Maximize  Restore  History

Download this file

29 lines (23 with data), 793 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require_once("java/Java.inc");
$passwd="hello";
try {
java_require("mail.jar"); // mail.jar is not part of the standard jdk
$password=new java("java.lang.String", "$passwd");
$algorithm=java("java.security.MessageDigest")->getInstance("md5");
$algorithm->reset();
$algorithm->update($password->getBytes());
$encrypted = $algorithm->digest();
$out = new java("java.io.ByteArrayOutputStream");
java_inspect(java("javax.mail.internet.MimeUtility"));
$encoder = java("javax.mail.internet.MimeUtility")->encode($out, "base64");
$encoder->write($encrypted);
$encoder->flush();
echo new java("java.lang.String",$out->toByteArray()); echo "\n";
exit(0);
} catch (Exception $e) {
echo "Echo invocation failed: $e\n";
//print_r ($e->getTrace());
exit(1);
}
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.