Post Script Secret Key Decryption
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello all,
I can manually decrypt the encryptedSecret property from an API endpoint with Postman using the Post-request Script. How can I do this with ServiceNow?
var jsonData = JSON.parse(responseBody);
var newencryptedSecret = jsonData.encryptedSecret;
var bytes = CryptoJS.AES.decrypt(newencryptedSecret, key);
var newSecret = bytes.toString(CryptoJS.enc.Utf8);
console.log("here's new Secret");
console.log(newSecret);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Try this one, Same kind of requirement we have implemented.
This is working fine for us.
Create a sys_properties with type password.
Update your value . After save , value will be encrypted. //Using fix script /other script like script include ->call from flow ,decrypt it as per your requirement.
Sample code :
// Get the encrypted value from the system property
var encryptedPassword = gs.getProperty('my_encrypted_password_property');
// Create a new GlideEncrypter object
var encrypter = new GlideEncrypter();
// Decrypt the value
var decryptedPassword = encrypter.decrypt(encryptedPassword);
// Now you can use the decryptedPassword variable
gs.info('The decrypted password is: ' + decryptedPassword);
