About Password (2 Way Encrypted) type and REST API

Koki
Tera Contributor

Hi.

There is a field "password" of type Password (2 Way Encrypted) in one table.

How can we decrypt and retrieve the value of the "password" field from outside of ServiceNow using the REST API and Power Shell?

Is it possible?
Can someone please tell me exactly how to do this?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I don't think using table API you can get that

you would require scripted rest api and decrypt and then send the value in API response

script to decrypt

how to decrypt the password2 (2 way encryption) field in scoped application

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I don't think using table API you can get that

you would require scripted rest api and decrypt and then send the value in API response

script to decrypt

how to decrypt the password2 (2 way encryption) field in scoped application

Regards
Ankur

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

@Koki 

Did you mistakenly marked other response as correct?

The same details were shared by me as 1st response to your question.

You can only mark 1 response as correct.

Would you mind marking the response based on timely response.

Regards
Ankur

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

Maik Skoddow
Tera Patron
Tera Patron

Hi @Koki 

OOTB there is no API available to return the decrypted value of a field.

Instead you have to build a Scripted REST API which does the decryption:

var objEncrypter = new GlideEncrypter();  
var strDecrypted = objEncrypter.decrypt('<YOUR ENCRYPTED VALUE>');  

Kind regards
Maik