My pre-request script has this.
var crypto = require('crypto-js');
I get this warning:
Using “crypto-js” library is deprecated. Use global “crypto” object instead.
How can I fix this?
My pre-request script has this.
var crypto = require('crypto-js');
I get this warning:
Using “crypto-js” library is deprecated. Use global “crypto” object instead.
How can I fix this?
Hey @jimjonah
Welcome to the Postman Community!
Although the library is deprecated, it’s not going to be going away soon so you’re ok to still use that.
We have also just released a new feature, in the latest version that allows you to use external packages in the sandbox - you should be able to modify your script to this:
const crypto = pm.require('npm:[email protected]')
For example:
const crypto = pm.require('npm:[email protected]');
// Encrypt
var ciphertext = crypto.AES.encrypt('my message', 'secret key 123').toString();
// Decrypt
var bytes = crypto.AES.decrypt(ciphertext, 'secret key 123');
var originalText = bytes.toString(crypto.enc.Utf8);
console.log(originalText)