class Crypto {

    public static String sign(String message, byte[] key) {
        if (key.length == 0) {
            return message;
        }

        try {
            Mac mac = Mac.getInstance("HmacSHA1");
            SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
            mac.init(signingKey);
            byte[] messageBytes = message.getBytes(Charsets.UTF_8);
            byte[] result = mac.doFinal(messageBytes);
            return BaseEncoding.base64().encode(result);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

}