How to use/replace GlideEncrypter for scoped app?

aklimenko
Mega Expert

We use GlideEncrypter in these cases. Is it supported in scoped app or how can we rewrite it?

1. encrypter.reencryptForAutomation() to encrypt pass

2. new GlideEncrypter().decrypt(creds.password); to decrypt

22 REPLIES 22

Thanks Saurabh! Works like a charm.


Hi Saurabh



I tried using gr.<element>.getDecryptedValue() but still its not working. Can you please tell me exactly how to use it??




Thanks




Amar


Is the target password field type set to "Password (2 Way Encrypted)"? I tried it first with "Password (1 Way Encrypted)" and it failed. Changing it to the other field type allowed gr.<element>.getDecryptedValue() to succeed.


Hey Ryan,


Wanted to give you some background here.



Password1 uses SHA hashing algorithm to convert the text into a hash and store it in the database. Theoretically no one would be able get the original text back with the computational power we have. This is best suited for user password fields. While checking for authentication, the password entered on the form, will be converted to hash using the same hashing algo and compared with the hash stored in the database.



But password2 is an encryption method. You encrypt using a public key and decrypt back to the original text using the private key. This can be used for storing the API keys, third party credentials and others which you have p a way to obtain the original text programatically. That's the reason gr.field.getDecryptedValue() works only on the password2 field.



Hope this helps.



Regards,


Pavan


Security Engineer - Store Certification


ServiceNow


pavanw3b


Hey Pavan,



That's really interesting! Thank you for the background. Is that in the documentation somewhere? If not, your descriptions of Password1 and Password2 along with mentioning that "getDecryptedValue" exists, would be EXCELLENT additions to the documentation .



Cheers,


Ryan