Facing issues in password decryption

saba tanveer
Tera Contributor

I am sending encrypted value from subflow to virtual agent flow. In subflow, there is OOTB action 'Generate Random Password' which consists of a script for generating random password. In this script step, below line is returning encrypted password :

return sn_fd.GlideActionUtil.setEncryptedOutput((new global.ScopedEncrypter).encrypt(newPwd));

when this encrypted value is returned in virtual agent flow it shows the decrypted value:

var stringValue = vaInputs.new_password.getValue();
var strLength = stringValue.length;
var startPos = (strLength - 27)
var encryptValue = stringValue.substr(startPos,24);
var encrypter = new GlideEncrypter();
return 'Your new password is: ' + encrypter.decrypt(encryptValue);
 
output is:
find_real_file.png
 
but sometimes it is not working fine and giving the output like that:
find_real_file.png
Kindly tell me the cause of this output and also the solution.
Thankyou.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So it's failing intermittently?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

yes

Maik Skoddow
Tera Patron
Tera Patron

Hi

it seems that you have not provide all information because in the following code lines it is not clear why are cutting out only a part of the passed string

var strLength = stringValue.length;
var startPos = (strLength - 27)
var encryptValue = stringValue.substr(startPos,24);

And whatever the reason is, it seems to me not correct.

Kind regards
Maik