Here’s some examples of using GlideEncrypter.

var encrypter = new GlideEncrypter();
// or GlideEncrypter('24 character string');

Encrypt & Decrypt

An important note, if you are setting a Password2 field, you must encrypt the value first otherwise the value will be stored in clear text and decrypting it may provide an incorrect value.

var encrypter = new GlideEncrypter();
var encrypted = encrypter.encrypt('Super Secret Phrase');
gs.info('encrypted: ' + encrypted);
var decrypted = encrypter.decrypt(encrypted);
gs.info('decrypted: ' + decrypted);
/**
*** Script: encrypted: g/bXLJHa7xNRMKZEo5q/YtLMEdse36ED
*** Script: decrypted: Super Secret Phrase
*/

Scoped Decrypt

gr.password.getDecryptedValue()