package org.jivesoftware.smack.util;

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

public class MD5 {
   private static MessageDigest MD5_DIGEST;

   public static synchronized byte[] bytes(byte[] bytes) {
      return MD5_DIGEST.digest(bytes);
   }

   public static byte[] bytes(String string) {
      return bytes(StringUtils.toBytes(string));
   }

   public static String hex(byte[] bytes) {
      return StringUtils.encodeHex(bytes(bytes));
   }

   public static String hex(String string) {
      return hex(StringUtils.toBytes(string));
   }

   static {
      try {
         MD5_DIGEST = MessageDigest.getInstance("MD5");
      } catch (NoSuchAlgorithmException var1) {
         throw new IllegalStateException(var1);
      }
   }
}
