Unable to Decrypt 2-Way Encrypted Password Field (Password2 Type) – Access Denied to Cryptographic

gautam_dhamija
Tera Contributor

Hi Community, 👋

I'm working on decrypting a Password (2 Way Encrypted) field in a custom table in ServiceNow. Here's the code I'm using in a background script to test decryption:

var rec = new GlideRecord("my_table");
if (rec.get("941b315a87b06a106a6dc8070cbb35a2")) {
var encr = new GlideEncrypter();

var encrString = encr.encrypt(rec.key);
var decrString = encr.decrypt(rec.key);

gs.print("Decrypted string = " + decrString);
}

However, I’m getting the following error in the logs:

Access Denied to cryptographic module 'global.com_snc_core_automation_glideencrypter'
For guidance on this issue, please have your Security Admin refer to KB: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1112530 : no thrown error
Access denied to crypto module
string may not be encrypted: Input length must be multiple of 8 when decrypting with padded cipher
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@gautam_dhamija 

are you using column level encryption?

are you in scoped app?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur,

Thanks for your response!

Yes, the field I'm trying to decrypt is a Password2 type, so I believe it uses column-level encryption internally.
And no, I’m currently working in the global scope, not a scoped app.

Let me know if you need any additional details. 

@gautam_dhamija 

can you share your business requirement here?

can you check this?

Unable to decrypt Key Store password after upgrading to San Diego 

also this

Getting decrypted value from Password2 field 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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