Encode String to MD5 Encryption

In cryptography, MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function with a 128-bit hash value. As an Internet standard (RFC 1321), MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of files. However, it has been shown that MD5 is not collision resistant; as such, MD5 is not suitable for applications like SSL certificates or digital signatures that rely on this property. An MD5 hash is typically expressed as a 32 digit hexadecimal number.
package md5;
import java.security.MessageDigest;
public class Main
{
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
String passwd = "azer89";
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(passwd.getBytes("UTF8"));
byte s[] = m.digest();
String result = "";
for (int i = 0; i < s.length; i++) {
result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
}
System.out.println(result);
}
}
Source :
http://en.wikipedia.org/wiki/MD5









SocialVibe