hmacSHA256(Hex decimal hash) signature generation with CryptoJS in servicenow

dayalsingh
Kilo Explorer

Hello Guys,

-1

I am using cryptoJS Lib for generating Hex HMACSHA256 signature for AWS4 request.Its working fine in custom application scope but in sn_capi scope throws me error undefined properties.

gist.github.com/igable/4bdcd90f78a8b2b07581 ..I have used this cryptojs file in the above link in my servicenow "script include" which is in sn_capi/cloud API scope when i hit this code with command var CryptoJS = new sn_capi.Crypto().CryptoJS; var kRegion = CryptoJS.HmacSHA256('regionName', 'kDate'); gs.info(kRegion); to get the hash i gets an error "undefined properties" at lines 1,8,50,149,186 but this works fine in custom application scope.I am able  to generate hash value in custom application scope but fails in sn_capi scope.Can anyone guide me on this.

Hey @dave.slusher can you guide me on this.

@Chuck Tomasi @Pradeep Sharma @Brad Tilton 
@Mark Stanger 
@Anurag Tripathi 
@josh.nerius 
@Göran Lundqvist 

 

11 REPLIES 11

Thank you Miguel for your reply. We cannot make Custom application scope just to sit one  Script Include (functionality) ,as its  chargeable.I was wondering  why its not working for SN scope application. sn_capi (Cloud API) scope is used to integrate cloud platforms with service now.Servienow should have at least supported to run CryptoJs file on cloud API scope.

That is a good question and I don't have an answer for you. I do know that SN has released AWS spokes for integration Hub to help with AWS integration. I am currently looking into the new AWS S3 spoke to replace my code. 

ShAn21
Tera Guru

Hi @dayalsingh 

Did you find any answer for this. I am getting an error called 'Cannot read property "init" from undefined ' for the function new scope.Crypto().CryptoJS.HmacSHA256(message, new scope.Crypto().CryptoJS.enc.Hex.parse(key_hex)).toString(new scope.Crypto().CryptoJS.enc.Hex);

 

Thanks

Hello @ShAn21 ,

 

I was able to able to implement this ,I did this in global scope later use

HI @Dayal Singh 

 

Could you please share how you made it to work in Global scope?

For me the below script works as is in script include but only works in custom scope and not in Global.

https://gist.github.com/vetsin/117cfe99ab0f87c1ac2d5c6387d1f7b4

 

Thanks