/*
 * Decompiled with CFR 0.152.
 */
package org.jivesoftware.smack.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.jivesoftware.smack.util.StringUtils;

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 SHA1.bytes(StringUtils.toBytes(string));
    }

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

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

    static {
        try {
            SHA1_DIGEST = MessageDigest.getInstance("SHA-1");
        }
        catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException(e);
        }
    }
}
