How to set encryption context in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 09:55 AM
How do you set your encryption context in a script. We have a couple of contexts available in sys_encryption_context.
I want to choose one of them before using the GlideEncrypter object.
Example
var a = new GlideRecord ('sys_encryption_context);
a.get ('name', 'my context')
callSomethingToSetContext(a.sys_id)
var x = new GlideEncrypter();
y = x.encrypt();
or
y = x.decrypt();
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 11:55 AM
If you read all the docs on GlideEncrypter it uses a "System" key that all the instances have and has nothing to do with encryption contexts. You can use your own key which the docs talk about is a string that is 24 chars.
I don't have the Encrypted field plugin installed, but you could try and enumerate all of the methods of a GlideElement for a field that is encrypted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 12:29 PM
you can pass the GlideDecripter a key, so I though I would be clever and pass it the key of the encryption context. Didn't work... 😞