title: java equivalent to php's hmac-SHA1
body: <p>I'm looking for a java equivalent to this php call:</p>
  
  <pre><code>hash_hmac('sha1', "test", "secret")
  </code></pre>
  
  <p>I tried this, using <a href="http://docs.oracle.com/javase/7/docs/api/javax/crypto/Mac.html" rel="noreferrer">java.crypto.Mac</a>, but the two do not agree:</p>
  
  <pre><code>String mykey = "secret";
  String test = "test";
  try {
      Mac mac = Mac.getInstance("HmacSHA1");
      SecretKeySpec secret = new SecretKeySpec(mykey.getBytes(),"HmacSHA1");
      mac.init(secret);
      byte[] digest = mac.doFinal(test.getBytes());
      String enc = new String(digest);
      System.out.println(enc);  
  } catch (Exception e) {
      System.out.println(e.getMessage());
  }
  </code></pre>
  
  <p>The outputs with key = "secret" and test = "test" do not seem to match.</p>