Skip to content

Instantly share code, notes, and snippets.

@maxhodak
Created November 23, 2012 03:48
Show Gist options
  • Save maxhodak/4133925 to your computer and use it in GitHub Desktop.
Save maxhodak/4133925 to your computer and use it in GitHub Desktop.
gox
def sign(request: String): String = {
val mac = Mac.getInstance("HmacSHA512")
mac.init(new SecretKeySpec(Base64.decodeBase64(encodedSecret), "HmacSHA512"))
Base64.encodeBase64String(mac.doFinal(request.getBytes))
}
val nonce = System.nanoTime() / 1000000
val req = url("https://mtgox.com/api/1/generic/bitcoin/address") <:< Map(
"User-Agent" -> "useragentname",
"Rest-Key" -> apikey,
"Rest-Sign" -> b64encode(sign("nonce=%s".format(nonce)))
) << "nonce=%s".format(nonce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment