Using encryption (sjcl) in Google Apps Scripts

Gunar Gessner

Gunar Gessner

Jul 8, 2020

function encrypt(salt, object) {
  const module = { exports: {} };
  eval(
    UrlFetchApp.fetch(
      "https://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.8/sjcl.min.js"
    ).getContentText()
  );
  sjcl = module.exports;

  return Utilities.base64Encode(sjcl.encrypt(salt, JSON.stringify(object)));
}

Comments

Be the first!