How to query records using encrypted text

Muhammad Ahsan
Tera Contributor

I have created a string field "Product ID" of length 210 characters on catalog item table and then populated it with 200 long characters encryted text, but I am not able to query it, not even using GlideRecord, how can I solve this issue?

MuhammadAhsan_0-1698745513529.pngMuhammadAhsan_1-1698745554152.png

 

3 REPLIES 3

Aniket Bhanse
Tera Guru

@Muhammad Ahsan 

you can decrypt the string from this code

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

 

You can either use this in the "Calculated Value" field of your table field OR you can create a new field and populate the decrypted value in the new field. 

 

Let me know if this helps you and mark it as helpful or Correct based on impact

OlaN
Giga Sage
Giga Sage

Hi,

Using an encrypted field suggests that you have some sensitive data in this field.

If so, why would you want to query this data?

 

Consider this scenario;

You query users with a certain password phrase, that gives results. This would mean you have gained access to that sensitive/protected field. You would know which user has which password.

That would be a severe security risk!

Basically it is a string in the encryted format, coming from the api response, I just saved it to the string field I customly created, but when I am using GlideRecord to query the records it just don't get the record.