Create MD5 String : MD5 « Security « Java






Create MD5 String

 
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5StringUtil
{
    private static final MessageDigest digest = MessageDigest.getInstance("MD5");

    public static String md5StringFor(String s)
    {
        final byte[] hash = digest.digest(s.getBytes());
        final StringBuilder builder = new StringBuilder();
        for (byte b : hash)
        {
            builder.append(Integer.toString(b & 0xFF, 16));    
        }
        return builder.toString();
    }
}

   
  








Related examples in the same category

1.OTP one-time password calculationOTP one-time password calculation
2.Applet to serve as an s/key calculator application wrapper around otp class
3.Creating a Keyed Digest Using MD5
4.MD5 BASE64 checksum for the specified input string.
5.MD5 InputStream
6.Implements MD5 functionality on a stream.
7.Fast implementation of RSA's MD5 hash generator in Java JDK Beta-2 or higher
8.MD5 algorithm RFC 1321
9.Contains internal state of the MD5 class
10.MD5 string
11.MD5 Sum
12.MD5 Hashing utility that builds up a hash from a series of objects and base types fed into it.
13.MD5 MessageDigest
14.Get MD5 string