Skip to content

Commit 76ff67c

Browse files
authored
Create encryptAndDecryptNonPasswordFields.js
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.
1 parent ec25326 commit 76ff67c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//To Encrypt password field
2+
var grIncident = new GlideRecord('incident');
3+
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
4+
grIncident.setDisplayValue('u_pass', 'demo@123');
5+
grIncident.update();
6+
}
7+
//NOTE: You can't use the setValue() API for the Password2 field
8+
9+
//To print cipher text
10+
var grIncident = new GlideRecord('incident');
11+
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
12+
gs.info('Encrypted cipher test of password ' + grIncident.getValue('u_pass'));
13+
}
14+
15+
//To decrypt password field
16+
var grIncident = new GlideRecord('incident');
17+
if (grIncident.get('dc1c4143476202101b589d2f316d4390')) {
18+
var result = grIncident.u_pass.getDecryptedValue();
19+
gs.info("Decrypted password- " +result);
20+
}
21+
//NOTE: The getDecryptedValue() API isn't scoped. It's available globally.

0 commit comments

Comments
 (0)