
import javax.crypto.SecretKey;
import javax.crypto.Mac;

/**
 * Created by IntelliJ IDEA.
 * User: Johnson Gong
 * Date: Feb 6, 2006
 * Time: 10:32:47 PM
 * To change this template use File | Settings | File Templates.
 */
public class MacMessage {
    public static byte[] doMac (byte[] msg, SecretKey sk) {
        byte[] macResult = new byte[0];
        try {
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(sk);
            mac.update(msg);
            macResult = mac.doFinal();
        } catch (Exception ex) {
            System.out.println(ex);
        }
        return macResult;

    }

}
