Converting node JS crypto code to crypto-js

Viewed 27

I have a nodejs script I run to generate a token, and I want to be able to do it in postman to allow myself to not have to manually generate a new auth token every time I wanna work on API calls.

In visual studio code, it uses crypto, and try as I have, I cannot get that library to function inside of postman, so I am trying to convert the code to crypto-js which is natively supported by postman but I keep running into issues. I'm not super well versed in crypto functions in general, so I'm having a hard time getting the code to perform the same actions before I generate a token in crypto-js. Is this even possible? If so could someone lend a hand?

   const crypto = require('crypto')  
   const load = 'stuff'
   const initial = crypto
           .createHmac('sha256', raw_key)
           .update(load, 'utf8')
           .digest('base64')

I then take that initial and combine it with load to generate the token. Then some other checks and stuff occur to get it to be a functional token that will be accepted, but I cannot get it to the point where initial will even fully generate for me to make it a token.

0 Answers
Related