Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HMAC signature
// base string - this string will be used to generate mac signature.
StringBuilder baseString = new StringBuilder();
* The order is CRITICAL! And no "\n" at the end.
* Timestamp + \n + nonce + \n+ httpmethod + \n +
* host + \n + path + \n + bodyHash
String newline = "\n";
// Generate signature using client secret (crypto initialized above)
byte[] signatureBytes = mac.doFinal(baseString.toString().getBytes(UTF8_ENCODING));
// now encode the cypher for the web
String signatureStr = Base64.encodeBase64String(signatureBytes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment