MD5 BASE64 checksum for the specified input string. : MD5 « Security « Java






MD5 BASE64 checksum for the specified input string.

   

import javax.swing.JOptionPane;

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

/**
 * MD5 common utils. Check and calculate MD5 BASE64 sum.
 * 
 * @author Luigi Zurolo - Liscio Luca
 * @version 1.1
 */
public class MD5 {



  /**
   * MD5 BASE64 checksum for the specified input string.
   * 
   * @param input -
   *          Specified input string
   * @return String - MD5 BASE64 sum
   */
  public static String checkMD5(String input) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(input.getBytes());
      byte[] enc = md.digest();
      String md5Sum = new sun.misc.BASE64Encoder().encode(enc);
      return md5Sum;
    } catch (NoSuchAlgorithmException nsae) {
      System.out.println(nsae.getMessage());
      return null;
    }
  }
}

   
    
    
  








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 InputStream
5.Implements MD5 functionality on a stream.
6.Fast implementation of RSA's MD5 hash generator in Java JDK Beta-2 or higher
7.MD5 algorithm RFC 1321
8.Contains internal state of the MD5 class
9.Create MD5 String
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