GlideEncrypter API is Depricated - needs alternative

Bheemsagar
Tera Contributor

Hello,

 

I am facing an issue, as the GlideEncrypter is deprecated, I  need to modify an existing script in my instance but the alternatives are not working for me. 

Reference article: Alternative Encryption Products to GlideEncrypter - Support and Troubleshooting (servicenow.com) - KB1320986 

 

My original script Include:

var FTVGlobalScopeUtils = Class.create();
FTVGlobalScopeUtils.prototype = {
    initialize: function() {},
    sleep: function(duration) {
        gs.sleep(duration);
    },
    //Takes an encrypted string as input parameter and returns decrypted string
    getDecryptedPassword: function(paramPassword){
        var encr = new GlideEncrypter();  
        var decrString = encr.decrypt(paramPassword);
        return decrString;      
    },
   
    //Takes a string as input parameter and returns encrypted string
    getEncryptedPassword: function(paramPassword){
        var encr = new GlideEncrypter();  
        var encrString = encr.encrypt(paramPassword);
        return encrString;      
    },

    type: 'FTVGlobalScopeUtils'
};
 
My Modified Script:
var FTVGlobalScopeUtils = Class.create();
FTVGlobalScopeUtils.prototype = {
    initialize: function() {},
    sleep: function(duration) {
        gs.sleep(duration);
    },
    // Takes an encrypted string as an input parameter and returns the decrypted string
    getDecryptedPassword: function(paramPassword) {
        var decrString = paramPassword.getDecryptedValue(paramPassword);
        return decrString;
    },
    // Takes a string as input parameter and returns encrypted string
    getEncryptedPassword: function(paramPassword) {
        var encrString = paramPassword.getEncryptedValue(paramPassword);
        return encrString;
    },
    // Add other utility methods as needed
    type: 'FTVGlobalScopeUtils'
};
 
Can someone please help me fix this script? I am not able to get the Decrypted and Encrypted passwords with new modifications.
 
Thank you.
2 REPLIES 2

Aman Jalan
Tera Contributor

Hey @Bheemsagar , In case you have resolved the issue. Could you please share the results here.

fabinamehar
Tera Contributor

To resolve this, you can replace the GlideEncrypter with the GlideCryptoModule. Here’s how you can modify your script:

Steps to Replace GlideEncrypter:

  1. Use GlideCryptoModule: Replace instances of GlideEncrypter with GlideCryptoModule.getModule(global.glide_encrypter_decrypter);. "global.glide_encrypter_decrypter" refers to the Cryptographic module name Ensure you have the Key Management role to create and manage cryptographic modules.

  2. Create a Cryptographic Module: If you haven't already, create a cryptographic module in your instance that supports both encryption and decryption.

  3. Module Access Policy: Ensure you set up a module access policy that allows your script to access the new cryptographic module.

Example script:

var FTVGlobalScopeUtils = Class.create();
FTVGlobalScopeUtils.prototype = {
initialize: function() {},

sleep: function(duration) {
gs.sleep(duration);
},


getDecryptedPassword: function(paramPassword) {
var cryptoModule = GlideCryptoModule.getModule(global.glide_encrypter_decrypter);
var decrString = cryptoModule.decrypt(paramPassword);
return decrString;
},


getEncryptedPassword: function(paramPassword) {
var cryptoModule = GlideCryptoModule.getModule(global.glide_encrypter_decrypter);
var encrString = cryptoModule.encrypt(paramPassword);
return encrString;
},

type: 'FTVGlobalScopeUtils'
};

 

Make sure the Cryptographic module supports encryption and decryption and Don't forget to create Module access Policy. Set the default module access policy value to “Track” and Mention your script table and Name in the policy.