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