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

One thought on “Use MD5 in android

Leave a comment