JAVA32 to MD5 encryption

Source: Internet
Author: User
Tags md5 encryption

Code, such as the following

<span Style= "FONT-SIZE:18PX;" >import Java.security.messagedigest;import Java.security.nosuchalgorithmexception;public class Main {public static void Main (string[] args) {main main = new main (); System.out.println (Main.encryption ("xiaowen123"));} /** * * @param plaintext * Clear text * @return 32-bit ciphertext */public string encryption (string plaintext) {string MD5 = new S Tring (); try {messagedigest MD = messagedigest.getinstance ("MD5"); Md.update (Plaintext.getbytes ()); byte b[] = Md.digest (); int i; StringBuffer buf = new StringBuffer (""); for (int offset = 0; Offset < b.length; offset++) {i = b[offset];if (i < 0) i + = 256;if (i < +) Buf.append ("0"); Buf.append (integer.tohexstring (i));} MD5 = Buf.tostring ();} catch (NoSuchAlgorithmException e) {e.printstacktrace ();} return MD5;}} </span> 

Specific address: http://java.662p.com/thread-3792-1-1.html

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

JAVA32 to MD5 encryption

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.