Copying Encrypted Field Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 07:19 AM - edited 11-23-2023 07:20 AM
I have a field sn which is encrypted. I want to copy this field value into another form.
This is the Script Include:
var EncryptionUtils = Class.create();
EncryptionUtils.prototype = {
initialize: function() {
},
getDecryptedValue: function(encryptedValue) {
var encrypter = new GlideEncrypter();
return encrypter.decrypt(encryptedValue);
},
type: 'EncryptionUtils'
};
And this is the script (which is part of a UI Action):
var ga = new GlideAjax('EncryptionUtils');
ga.addParam('sysparm_name', 'getDecryptedValue');
ga.addParam('sysparm_encrypted_value', sn); // Pass the encrypted value to the server
ga.getXMLAnswer(function(response) {
var decryptedValue = response;
// Now you can use the decrypted value as needed
dialog.setPreference("sysparm_sn", decryptedValue);
However this is not working. Any suggestions on how to make it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2023 08:32 AM
Hi @vidhya_mouli,
The encrypted fields has two field classes there are password (1 Way Encrypted) and password (2 Way Encrypted)
the GlideEncrypter() method won't works for password (2 Way Encrypted) field type. I tried with password (1 Way Encrypted) able to encrypt and decrypt the values stored in this field.
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.