- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 10:34 PM
GlideEncrypter in scoped app?
Create a new script include in the global context that takes your string value as a parameter and then use GlideEncrypter to do the work for you inside the script include function. You then return the the encrypted value to your calling script. In order to call the new include from a scope application script you can use similar to the following:
var encryptmypwd = new global.myEncrypterInclude(); //Note the global prefix
var encryptedpwd = encryptmypwd.encryptPwd("myrandompasswordstring");
encryptPwd above is the function inside my new script include that uses GlideEncrypter to encrypt for me
CAN SOMEONE help me with this? I want this to be implemented?
here is the link for more information on above mentioned description.
https://community.servicenow.com/community?id=community_question&sys_id=23fdc7addb9cdbc01dcaf3231f9619b6
Solved! Go to Solution.
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 02:11 AM
Create this script include in the global scope open to all scopes...
var Encrypter = Class.create();
Encrypter.prototype = {
initialize: function(key) {
this.ge = new GlideEncrypter(key);
},
encrypt: function(str){
return this.ge.encrypt(str);
},
decrypt: function(str){
return this.ge.decrypt(str);
},
type: 'Encrypter'
};
And you can use it like this in any scope...
var e = new global.Encrypter("abcdefghijklmnopqrstuvwx");
var secret = e.encrypt("test");
gs.info(secret); // => Zjem9344FZk=
gs.info(e.decrypt(secret)); // => test
Tested in background scripts from scoped app and this works fine (in Tokyo).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 02:11 AM
Create this script include in the global scope open to all scopes...
var Encrypter = Class.create();
Encrypter.prototype = {
initialize: function(key) {
this.ge = new GlideEncrypter(key);
},
encrypt: function(str){
return this.ge.encrypt(str);
},
decrypt: function(str){
return this.ge.decrypt(str);
},
type: 'Encrypter'
};
And you can use it like this in any scope...
var e = new global.Encrypter("abcdefghijklmnopqrstuvwx");
var secret = e.encrypt("test");
gs.info(secret); // => Zjem9344FZk=
gs.info(e.decrypt(secret)); // => test
Tested in background scripts from scoped app and this works fine (in Tokyo).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 03:29 AM
Hi
Thank You So Much. Its working.
I have few questions which encryption algo does it uses AES-128 or AES-256.
var e = new global.Encrypter("abcdefghijklmnopqrstuvwx");
What is this parameter passed to encrypter function? Is it secret key?
Can we pass some different value? and why its not complete abcdef....xyz , I can see yz is missing. Can you help me to understand this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 03:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 03:50 AM
Understood very well. Thank You So Much John!! :)✌