Decryption of Sys_property failing.

andinh-vu
Mega Contributor

Hi Team,

I am trying to testing why the decrpytion of a password is failing.

I have a field in the sys_properties set as password2 for security purposes.

As per article below.

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/encryption/task/t_Enc...

 

and this is the snip of code i have taken from the script include that decrypts it for rest messages.

which i have modified to test using background script.

 

Var userPass = "encrypted Sys_property";           // Decrypt password     var Encrypter = new GlideEncrypter();       var encrText = userPass; // current.<<your field name>>       var decrText = Encrypter.decrypt(encrText); gs.print(encrText); gs.print(decrText);

 

the two fields i have printed show exactly the same value and i get this error at the top of the background script.

Input length must be multiple of 8 when decrypting with padded cipher


any ideas why it seems like its no working?
1 ACCEPTED SOLUTION

andinh-vu
Mega Contributor

Well this is sad,


it seems the encrypted password was encrypted twice over and broke.


View solution in original post

3 REPLIES 3

andinh-vu
Mega Contributor

Well this is sad,


it seems the encrypted password was encrypted twice over and broke.


Bryan Tay3
Mega Guru

hi Thai-An,



I think GlideEncrypter is to decrypt field/column value stored as "password2" type while sys_properties encrypted value are not stored as this type.


Instead, use "gs.getProperty('property_name')" to get the clear text value.



useful reference for forms contain password2 fields:


        https://servicenowgems.com/2017/08/30/decrypting-password-fields-automatically/



hope this helps.


Aditya Telideva
ServiceNow Employee
ServiceNow Employee

The below thread could be of some help to you: Decrypting a value to set as password not working