[Android] md5 encryption is performed when the mobile guard saves the password. androidmd5
Generally, the mobile phone does not have the root permission and cannot enter the data/data directory. When the mobile phone is flushed, it has the root permission and can enter the data/data directory to view the password file we saved, therefore, we need to perform MD5 encryption on the Stored Password.
Obtain the MessageDigest information digest object and call MessageDigest. getInstance ("md5"). Parameter: Rule
Call the digest (bytes) method of the MessageDigest object to obtain the encrypted byte [] array. The parameter is the byte [] array. Call the getBytes () method of the String object to obtain the byte array.
Perform and operate with each byte and 11111111 binary bits, and obtain the int type: byte & 11111111
For (byte B: xxxxx) loop
Run byte & 0xff to get the int Value
Call Integer. toHexString (number) to obtain hexadecimal notation and return the String type.
Judge that the length of a String is 1, and concatenate 0 on the front of it.
Define a StringBuffer object outside the loop, and call the append () of the StringBuffer object to splice the string.
Call the toString () method of the StringBuffer object to obtain the encrypted standard string.
MD5 can be cracked, including md5 (md5 (md5 (). All possibilities are encrypted and stored in the database, and then compared with your md5 password, md5 and salt can be performed.
The software needs to be uninstalled before testing to clear the previously saved sp files.
Package com. qingguow. mobilesafe. utils; import java. security. messageDigest; public class Md5Util {/*** obtain the MD5 encrypted String * @ param pass * @ return */public static String md5Password (String pass) {MessageDigest messageDigest; try {messageDigest = MessageDigest. getInstance ("md5"); byte [] bytes = messageDigest. digest (pass. getBytes (); StringBuffer sb = new StringBuffer (); for (byte B: bytes) {int number = B & 0xff; String str = Integer. toHexString (number); if (str. length () = 1) {sb. append ("0");} sb. append (str);} return sb. toString ();} catch (Exception e) {e. printStackTrace ();} return "";}}