/** Default constructor. */
 public DigestServerAuthenticationMethod() {
   try {
     messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM);
   } catch (NoSuchAlgorithmException ex) {
     ProxyDebug.println("Algorithm not found " + ex);
     ex.printStackTrace();
   }
   passwordTable = new Hashtable();
 }
예제 #2
0
 /**
  * Returns an MD5 hash.
  *
  * @param pw String
  * @return String
  */
 private static String md5(final String pw) {
   final StringBuilder sb = new StringBuilder();
   try {
     final MessageDigest md = MessageDigest.getInstance("MD5");
     md.update(pw.getBytes());
     for (final byte b : md.digest()) {
       final String s = Integer.toHexString(b & 0xFF);
       if (s.length() == 1) sb.append('0');
       sb.append(s);
     }
   } catch (final NoSuchAlgorithmException ex) {
     // should not occur
     ex.printStackTrace();
   }
   return sb.toString();
 }