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

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

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

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