The CreatorCon Call for Content is officially open! Get started here.

Amit Gujarathi
Giga Sage
Giga Sage

In this video, we learn the ServiceNow GlideEncrypter API. ServiceNow Decrypt Password can be done via GlideEncrypter API .IN this video we are gonna decrypt the encrypted password to get the decrypted password.

GlideEncrypter provides methods to encrypt and decrypt strings using the Triple-DES algorithm. The GlideEncrypter class is used in server scripts in the global scope. The GlideEncrypter class has two constructors:

  • GlideEncrypter()
  • GlideEncrypter()

Creates an instance of the GlideEncrypter class using a default (static) encryption key.

Example

var encr = new GlideEncrypter(); 
GlideEncrypter(String key)

Creates an instance of the GlideEncrypter class using a given encryption key. Parameters Name Type Description key String Your encryption key must be exactly 24 characters. A key longer than 24 characters will be truncated.

Example

var encr = new GlideEncrypter(myKey); 
decrypt(String encryptedString)

Decrypts a clear string using the Triple DES algorithm.

Parameters Name Type Description encryptedString String String to be decrypted. Returns Type Description String Clear text string.

Example

var encr = new GlideEncrypter(); 
var clearString = 'abcdefg'; 
var encrString = encr.encrypt(clearString);
var decrString = encr.decrypt(encrString);  
gs.print("Decrypted string = " + decrString);
Decrypted string = abcdefg

 

Please put it in the comments which you wanna see in the future. If this video is helpful then, please do not forget to like, subscribe and share my youtube channel Technomonk.

Comments
DrewW
Mega Sage

You missed the "reencryptParamForAutomation" method.  Which if you are doing automations I think is the most important one.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0856481

Conveniently it is missing from the Docs site.  The example code in the KBA is assuming you are using it in a flow activity.

AlessandroD
Tera Contributor

Sadly, the GlideEncrypter API is going to be deprecated by ServiceNow, so this is no longer valid. The deprecation has been postponed I think to Zurich, so customer has still some time to revert to some alternatives.

 

Here a ServiceNow KB with alternatives to GlideEncrypter:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1320986

 

For decrypting a password2 field value from a GlideRecord, it would be as simple as calling gr.field_name.getDecryptedValue();

Same for encrypting a value in a password2 field, we can just call the setDisplayValue and passing the plain text value.

 

There are use cases, though, for example when sending a parameter to a probe, where we don't want to send it as plain text. Before we were using reencryptParamForAutomation from the GlideEncrypter API, while now due to the deprecation, we could use:

SNC.ParameterEncrypter.encrypt(plaintextValue); 
before passing the parameter to the probe. The above mentioned method is not documented anywhere, or at least I haven't found it anywhere. However, this is what ServiceNow use in their JDBCProbe 🙂 
 
 
AlessandroD
Tera Contributor

Sadly, the GlideEncrypter API is going to be deprecated by ServiceNow, so this is no longer valid. The deprecation has been postponed I think to Zurich, so customer has still some time to revert to some alternatives.

 

Here a ServiceNow KB with alternatives to GlideEncrypter:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1320986

 

For decrypting a password2 field value from a GlideRecord, it would be as simple as calling gr.field_name.getDecryptedValue();

Same for encrypting a value in a password2 field, we can just call the setDisplayValue and passing the plain text value.

 

There are use cases, though, for example when sending a parameter to a probe, where we don't want to send it as plain text. Before we were using reencryptParamForAutomation from the GlideEncrypter API, while now due to the deprecation, we could use:

SNC.ParameterEncrypter.encrypt(plaintextValue); 
before passing the parameter to the probe. The above mentioned method is not documented anywhere, or at least I haven't found it anywhere. However, this is what ServiceNow use in their JDBCProbe.
 
 
Version history
Last update:
‎10-11-2022 02:42 AM
Updated by:
Contributors