Use MD5 in android

One of the most important thing for password security is encryption of password.
For that everyone give suggestion of cipher but MD5 is better way to use.Because it is near to impossible to break MD5 code.

//Convert string Password to MD5
public String convertToMD5(String pass) 
{
    try 
    {
        // Create MD5 Hash
        MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
        digest.update(pass.getBytes());
        byte messageDigest[] = digest.digest();

        // Create Hex String
        StringBuffer hexString = new StringBuffer();
        for (int i=0; i<messageDigest.length; i++)
            hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
        return hexString.toString();
    } 
    Catch (NoSuchAlgorithmException e) 
    {
        e.printStackTrace();
    }
    return "";
}

Just You need to pass String and it will return MD5 encrypted password

Advertisements

One thought on “Use MD5 in android

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s