Php and java are different in Chinese language md5

Source: Internet
Author: User
Is php different from java's Chinese md5? The project team wants to build a component to communicate with other companies. they are developed in php, java on our side, and md5 encryption on the URL address. every time I retrieve the component, an error occurs .. I am troubled by this problem for two or three days. Finally, I found that md5 in Chinese in java is different from md5 in php. there is no problem in English at all... solution 1: Do php and java write md5 on both sides to calculate the difference between php and java Chinese md5?
The project team wants to build a component to communicate with other companies. they are developed in php, java on our side, and md5 encryption on the URL address. every time I retrieve the component, an error occurs .. I am troubled by this problem for two or three days. Finally, I found that md5 in Chinese in java is different from md5 in php. there is no problem in English at all...
Solution 1: Write the md5 algorithm on both sides of php and java ..
Solution 2: Call the php page through java. the url parameter generates the md5 format and communicates with other companies.
The code is as follows:
Java:
Public static String EncoderByMd5 (String str, String url ){

Str = java.net. URLEncoder. encode (str, "gb2312"); CommHttpInterface http = new CommHttpInterface ();

Return http. phpRequest (url + "? "+ Str );
}

Public static String phpRequest (String url ){
Try {
HttpClient client = new HttpClient ();
PostMethod post = new PostMethod (url); // Use POST to submit data
Post. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");
Client.exe cuteMethod (post );
String response = new String (post. getResponseBodyAsString (). getBytes ("gb2312"); // print the result page
Post. releaseConnection ();
Return response;
} Catch (IOException e ){
E. printStackTrace ();
Return null;
}
}




Php:
Header ("Content-type: text/html; charset = gb2312 ");
$ ParamStr = urldecode ($ _ GET ["md5str"]);
Echo strtolower (md5 ($ paramStr ));
?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.