Copy link to clipboard
Copied
my knowledge to the crypt functions and the hmac is limited and i am still learning. I am trying to do this of Node JS code to Coldfusion but my results are not the same
const getMessageSignature = (path, request, secret, nonce) => {
const message = qs.stringify(request);
const secret_buffer = new Buffer(secret, 'base64');
const hash = new crypto.createHash('sha256');
const hmac = new crypto.createHmac('sha512', secret_buffer);
const hash_digest = hash.update(nonce + message).digest('binary');
const hmac_digest = hmac.update(path + hash_digest, 'binary').digest('base64');
return hmac_digest;
};
and i did some try in Coldfusion but i am not able to get right results
<cfset nonce = createobject("java","java.lang.System").currentTimeMillis()>
<cfset string_to_sign = "/0/private/TradeBalance" & hash(nonce, "SHA-512", "UTF-8")>
<cfset api_sign = tobase64(hmac(string_to_sign, "#secret_key#", "HMACSHA256"))>
Have something to add?