The CreatorCon Call for Content is officially open! Get started here.

How to set encryption context in script

pneuvil1
Mega Guru

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();
6 REPLIES 6

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.

 

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... 😞