0
rewriting the code for coldfusion for authentication in an API
New Here
,
/t5/coldfusion-discussions/rewriting-the-code-for-coldfusion-for-authentication-in-an-api/td-p/11805132
Feb 03, 2021
Feb 03, 2021
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"))>
TOPICS
Advanced techniques
,
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Have something to add?
Join the conversation

