0

I am trying to create a request in postman that pulls some parameters and puts them in the proper order and then hashes in sha256 hex. I understand I need to use a pre-request script but am struggling with what to use and how to get parameters in the script.

Example of the concatenate string - hex_sha256('[session:Key][session:Password][session:Sent][session:UnitAgencyTypeId][session:UnitName][session:UserInit][session:UserName][session:UserSub][session:Secret]')")]

Any help would be really appreciated

Matt
  • 57
  • 5

1 Answers1

1

The script sandbox provided by Postman includes crypto-js, which can be used to compute SHA256 hashes. This can be done as follows:

var SHA256 = require('crypto-js').SHA256,
    hash = SHA256('your_content_goes_here');

As for the parameters, it is possible to use various parts of a request, as well as Postman variables to construct the input for your hashing needs. See https://www.getpostman.com/docs/v6/postman/scripts/postman_sandbox_api_reference for a complete reference on all helpers provided by the Postman sandbox.

Kunal Nagpal
  • 776
  • 2
  • 7
  • 14
  • Here is what I am trying to emulate https://text-share.com/view/17eee472#oDnp9LCMSEA1kvuuglieQh1lc5PtdJBW But when I use this as a postman prescript I dont get the correct hash.. https://text-share.com/view/4fb6e6c2#spcpYWr9aFskrh5C6Qu8J9IUpserhfu6 Any ideas what I am doing wrong? – Matt Oct 26 '18 at 20:22