How to encrypt a password in scoped application?

Gazal Varshney2
Tera Contributor

Hi,

 

I have a requirement to encrypt a password in scoped aplication (security Incident Response). Please help me in achieving the target. I know how to do the same in global scope using GlideEncrypter().

 

var encr = new GlideEncrypter();
workflow.scratchpad.password = encr.encrypt(example);

 

but GlideEncrypter() does not work in scoped applications, kindly help me with an alternative to implement this requirement.

 

Thanks,

Gazal

1 ACCEPTED SOLUTION

Priyanka Chandr
Mega Guru

Hi,

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.

 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Priyanka

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

View solution in original post

4 REPLIES 4

Priyanka Chandr
Mega Guru

Hi,

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.

 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Priyanka

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi Priyanka,

 

This method worked. 🙂

 

Thanks a lot,

Gazal

Saurabh singh4
Kilo Guru

Hi Gazal

Try this code in business rule.

var Encrypter = new GlideEncrypter();  

 

var encrypted = current.u_password; // current.<<your field name>>  

 

var decrypted = Encrypter.decrypt(encrypted);  

 

gs.addInfoMessage("encrypted..   " + encrypted);  

 

gs.addInfoMessage("decrypted..   " + decrypted);

 

Please mark the reply as Helpful/Correct, if applicable.

Saurabh

Hey Saurabh,

 

I have tried ith new script include and calling it in my workflow. It worked 🙂

 

Thanks,

Gazal