package org.jivesoftware.smack.util;

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

public class SHA1 {
   private static MessageDigest SHA1_DIGEST;

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

   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 {
         SHA1_DIGEST = MessageDigest.getInstance("SHA-1");
      } catch (NoSuchAlgorithmException var1) {
         throw new IllegalStateException(var1);
      }
   }
}
