Android MD5 password encryption

Today I will show you how to generate the MD5 hash String for a given String in Android

 * function md5 encryption for passwords
 * @param password
 * @return passwordEncrypted
private static final String md5(final String password) {
	try {

		MessageDigest digest =
		byte messageDigest[] = digest.digest();

		StringBuffer hexString = new StringBuffer();
		for (int i = 0; i < messageDigest.length; i++) {
			String h = Integer.toHexString(0xFF & messageDigest[i]);
			while (h.length() < 2)
				h = "0" + h;
		return hexString.toString();

	} catch (NoSuchAlgorithmException e) {
	return "";

About cmanios

This entry was posted in Android, Java. Bookmark the permalink.

7 Responses to Android MD5 password encryption

  1. atif says:

    Thanks man! Couldn’t be more better.

  2. João Batista Ladchuk says:

    Tank You my friend! this work’s very nice!!

  3. vikas says:

    xtreamly thanks to u…….

  4. Shubham says:

    How can I decrypt it using C#

Leave a Reply

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

You are commenting using your 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