Skip to content

Encrypt and Decrypt Password Fields #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//To Encrypt password field
var grIncident = new GlideRecord('incident');
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
grIncident.setDisplayValue('u_pass', 'demo@123');
grIncident.update();
}
//NOTE: You can't use the setValue() API for the Password2 field

//To print cipher text
var grIncident = new GlideRecord('incident');
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
gs.info('Encrypted cipher test of password ' + grIncident.getValue('u_pass'));
}

//To decrypt password field
var grIncident = new GlideRecord('incident');
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
var result = grIncident.u_pass.getDecryptedValue();
gs.info("Decrypted password- " +result);
}
//NOTE: The getDecryptedValue() API isn't scoped. It's available globally.
10 changes: 10 additions & 0 deletions Background Scripts/encryptAndDecryptNonPasswordFields/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Dear ServiceNow Community,


The GlideEncrypter API uses 3DES encryption standard with NIST 800-131 A Rev2 has recommended against using to encrypt data after 2023. ServiceNow offers alternative cryptographic solutions to the GlideEncrypter API.

Glide Element API to encrypt/decrypt password2 values through GlideRecord.

Below are the sample scripts I ran in my PDI: For Password fields.

Note: 'u_pass' is Password (2 Way Encrypted) field.
Loading