GlideEncrypter API provides methods to encrypt and decrypt strings using the Triple DES algorithm. This API can be used in server scripts.
var encr = new GlideEncrypter();
var string = 'MyServiceNowStuff.com';
var encrString = encr.encrypt(string);
var decrString = encr.decrypt(encrString);
gs.print("Encryped string = " + encrString);
gs.print("Decrypted string = " + decrString);
*** Script: Encryped string = ZQ16PA3pnx8dhJxgrQZNxiBFhdtrslmP
*** Script: Decrypted string = MyServiceNowStuff.com
This can also be used to decypt certain password fields (like on Data Sources). Example:
var ds = new GlideRecord('sys_data_source');
ds.get('sys_id_of_record');
var encr = new GlideEncrypter();
var decrString = encr.decrypt(ds.jdbc_password);
gs.print("Decrypted string = " + decrString);
Documentation: https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server_legacy/GlideEncrypterAPI
Update: I’m happy to learn that ServiceNow is deprecating this GlideEncrypter API and this will no longer be permitted starting in 2024.
