code: private static String generateRecurlyHMAC(String privateJsKey, String protectedParams) {
          try {
              SecretKey sk = new SecretKeySpec(privateJsKey.getBytes(), "HmacSHA1");
              Mac mac = Mac.getInstance("HmacSHA1");
              mac.init(sk);
              byte[] result = mac.doFinal(protectedParams.getBytes("UTF-8"));
              return BaseEncoding.base16().encode(result).toLowerCase();
          } catch (Exception e) {
              log.error("Error while trying to generate Recurly HMAC signature", e);
              return null;
          }
      }
docs: HMAC-SHA1 Hash Generator - Helper method
  <p>
  Returns a signature key for use with recurly.js BuildSubscriptionForm.
  
  @param privateJsKey recurly.js private key
  @param protectedParams protected parameter string in the format: &lt;secure_hash&gt;|&lt;protected_string&gt;
  @return subscription object on success, null otherwise