Hello,
I'm writing a script to get results from a REST API.
To run this script, i have to put a header that is encrypted in sha256
Is there any method implemented in SageX3 to hash my content in sha256?
Thanks
Hi,
We can achieve this from the node.js. We have earlier worked on encryption in Base64 with node.js.
You can reach out to us on email at [email protected].
Thanks,
Dinesh
We use node.js for that, you execute it from inside 4GL, but it is much easier to do it in a global language like js. We did this for the Angolan Legislation, if you need we can share this know how. Cheers.
Thank you
I found an ancient original post here(https://www.sagecity.com/us/sage_erp_x3/f/sage-x3-general-discussion-forum/103623/hmac-sha256-encryption).
I will try this.
That's the way!
Hi, I finnaly started to develop the function with the base I found in Sage X3 Help on the Crypto bundle.
I changed a bit the code to encrypt in SHA256:
"use strict"; var crypto = require('crypto'); // computes hash in SHA256 digest, returns it as a hex string. exports.digestsha256(text) { var hash = crypto.createHash('sha256'); hash.update(text, 'utf8'); return hash.digest('hex'); }
But, when i run the X3 script
STATUSCODE = func ASYRWEBSER.EXEC_JS("bundles/yeth-crypto/lib/crypto-helper", "digestsha256", "sync", '"helloworld"', "0", 0, "", "0", RESHEAD, RESBODY)
The STATUSCODE is always 500, and I don't have
Have you any clue on that problem?
Thanks
I found the solution,
The sample in X3 help doesn't work as it is.
but with the keyword function, it's OK
"use strict"; var crypto = require('crypto'); // computes hash in SHA256 digest, returns it as a hex string. exports.digestsha256 = function(text) { var hash = crypto.createHash('sha256'); hash.update(text, 'utf8'); return hash.digest('hex'); }
*Community Hub is the new name for Sage City