Decrypt password 2 type field and used it to match with a field in catalog

Learn SN
Tera Contributor

i have password 2 type field in a table and i want to match it with a field on catalog item. how to do it ?

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

I suggest that you create a onChange client script on your catalog item and on input of your field, call a SI.

In SI, check out GlideEncrypter.decrypt of your password2 field and get your code decrypted and compare that with your field value of catalog item. If matches, return true, otherwise false.

Mark the comment as a correct answer and helpful if it helps.

View solution in original post

3 REPLIES 3

asifnoor
Kilo Patron

Hi,

I suggest that you create a onChange client script on your catalog item and on input of your field, call a SI.

In SI, check out GlideEncrypter.decrypt of your password2 field and get your code decrypted and compare that with your field value of catalog item. If matches, return true, otherwise false.

Mark the comment as a correct answer and helpful if it helps.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

use this code in server side; possibly in business rule;

If not in business rule then query the table and use the GlideRecord object

var Encrypter = new GlideEncrypter();  
var encrypted = current.<fieldName>; // current.<<your field name>>   
var decrypted = Encrypter.decrypt(encrypted);  
gs.info("decrypted..   " + decrypted);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

harishdasari
Tera Guru

Hi,

You can try as below code

var encr = new GlideEncrypter();

// give the password field name
var passwordField = "Field Name";  

// Encrpyting the password field.
var encrpytedpassword= encr.encrypt(passwordField);

// Now decrpyt the password
var decrpassword = encrpytedpassword.decrypt(encrpytedpassword);


gs.print("Decrypted string = " + decrpassword );

 

Hope this is Helpful