[Android] md5 encryption is performed when the mobile guard saves the password. androidmd5

Source: Internet
Author: User

[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 "";}}

 

Related Article

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.