Learn about java encryption and PHP, and help me solve it.

Source: Internet
Author: User
Learn about java encryption and PHP, and help me solve it. Importjava. security. messageDigest; Strings & quot; I am abc & quot; byte [] bs. getBytes (& quot; UTF8 & quot;); for (inti0; I & lt; B. length; I ++) {System. ou. learn about java encryption and PHP, and help me solve it.
Import java. security. MessageDigest;
String s = "I am abc ";
Byte [] B = s. getBytes ("UTF8 ");
For (int I = 0; I <B. length; I ++ ){
System. out. println (B [I]); // The byte array obtained here is the same as the php unpack ("c *", $ str.
}
System. out. println ("-------------");
MessageDigest md = MessageDigest. getInstance ("MD5 ");
Md. update (B );
Byte tmp [] = md. digest (); // The MD5 calculation result is a 128-bit long integer.
// The result is a 16-byte array.
For (int I = 0; I <tmp. length; I ++ ){
System. out. println (tmp [I]);
}

------ Solution --------------------
From the code you write, you have the ability to solve it on your own.
PHP code
$ Str = "I am abc"; $ B = unpack ("C *", md5 ($ str, 1); print_r ($ B );

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.