- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 03:54 AM
Hello Community,
How to decrypt the user password using script ?
I am trying below script but its not working
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID())
var Encrypter = new GlideEncrypter();
var decrypted = Encrypter.decrypt(gr.user_password);
gs.print(decrypted);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 03:57 AM
Hi there,
This does not work for the password field on sys_user (which is of type Password (1 Way Encrypted)).
This would work on for example the basic_auth_credentials table for the password field (which is of type (Password (2 Way Encrypted)).
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 04:02 AM
Also see:
"Password (1 Way Encrypted)
Text field that stores passwords with one-way encryption. One-way encryption stores the password as a secure hash value that cannot be decrypted."
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 04:00 AM
As Mark rightly said it cannot & reason is detailed in thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 04:03 AM
var Encrypter = new GlideEncrypter();
var encrypted = current.u_password; // current.<<your field name>>
var decrypted = Encrypter.decrypt(encrypted);
gs.addInfoMessage("encrypted.. " + encrypted);
gs.addInfoMessage("decrypted.. " + decrypted);
Sample script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 12:06 PM
That's incorrect. Read the responses.
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 11:20 PM
var gr = new GlideRecord('<table which holds the password field>');
gr.get('<sys_id of the record which has the passoword field>');
var Encrypter = new GlideEncrypter();
var encrypted = gr.<Name of the password field>;
var decrypted = Encrypter.decrypt(encrypted);
gs.print("encrypted.. " + encrypted);
gs.print("decrypted.. " + decrypted);