Send encrypted data via REST

User173809
Tera Contributor

We are attempting to pass an encrypted password value to our SNOW instance via REST API. I then want to be able to store this in a field (on the sys_user table) and be able to decrypt the value in order to send it via notification to an end user. This will be used in our onboarding process to be able to send randomized passwords for newly provisioned users to the hiring managers.

Is it possible to receive an encrypted value and have SNOW recognize that this is an encrypted value and then decrypt it via scripting?

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Allen,



May be you can refer below links


Encryption Scripting - ServiceNow Wiki


https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/script/server-scripting/referen...


Encryption Support - ServiceNow Wiki



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

User173809
Tera Contributor

I was able to partly find out the answer to my problem.



It seems that passing an encoded value via REST into the Encrypted Text field I created will automatically be recognized as being encrypted.



For example, a webservice call with the encrypted value below passed to u_testing field shows as blahblahblah when i view it on the form.


{


  "user_name":"testing6",


  "first_name":"blah",


  "last_name":"blah",


  "u_testing":"095811734fb232000b1438a18110c79e:muSQWGVl7N4GKH/zp8ZsPA=="


}



It appears that this value is the sys_id of the encryption context and the encoded string, however, i'm not able to manually encode my string to match the encoding that SNOW is using.



For example, if I have text blahblahblah, this is encoded to the value muSQWGVl7N4GKH/zp8ZsPA==, however, when using an AES-128 encoder, the encoded value is bxQ+3LsZmlDP3dn/11gt+Q==.



I did a few test with a couple of different encryption contexts and it was able to see that the same string of blahblahblah when encoded in SNOW and then decoded using my external site yields the same value, but it is not the original string. So it appears that either the external site which is encoding and decoding is incorrect or SNOW is doing something else I am unaware.'



By the way, the external site I am manually trying to encode and decode is AES encryption