MD5, i.e. "Message-digest algorithm 5 (Information-Digest algorithm)";
MD5 transforms the "byte string" of any length into a large integer of 128bit, and it is an irreversible string transform algorithm;
1 ImportJava.math.BigInteger;2 Importjava.security.MessageDigest;3 Importjava.security.NoSuchAlgorithmException;4 5 Public classUtility {6 Staticmessagedigest messagedigest;7 StaticString pwd;8 Public Staticstring getMD5 (string plaintext) {9 Try {Ten //generate a MD5 cryptographic calculation summary OneMessageDigest = Messagedigest.getinstance ("MD5"); A //Digest with new message in clear text - messagedigest.update (Plaintext.getbytes ()); - //Digest () finally determines the return MD5 hash value, and the return value is a 8-bit string. Because the MD5 hash value is a 16-bit hex value, it's actually a 8-bit character. the //The BigInteger function converts a 8-bit string to a 16-bit hex value, represented by a string, and a hash value in string form, where 1 represents a positive number and 0 represents a negative number for 0,-1. -PWD =NewBigInteger (1, Messagedigest.digest ()). ToString (16); - -}Catch(nosuchalgorithmexception e) { + e.printstacktrace (); - } + returnpwd; A } at}
Test 123456 of MD5 for e10adc3949ba59abbe56e057f20f883e
Java to Password MD5