How to use the jsencrypt/bin/jsencrypt function in jsencrypt

To help you get started, we’ve selected a few jsencrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prebid / Prebid.js / modules / adagioBidAdapter.js View on Github external
if (!ls) {
      utils.logWarn('Adagio Script not found');
      return;
    }

    const hashRgx = /^(\/\/ hash: (.+)\n)(.+\n)$/;

    if (!hashRgx.test(ls)) {
      utils.logWarn('No hash found in Adagio script');
      w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY);
    } else {
      const r = ls.match(hashRgx);
      const hash = r[2];
      const content = r[3];

      var jsEncrypt = new JSEncrypt();
      jsEncrypt.setPublicKey(ADAGIO_PUBKEY);

      if (jsEncrypt.verify(content, hash, sha256)) {
        utils.logInfo('Start Adagio script');
        Function(ls)(); // eslint-disable-line no-new-func
      } else {
        utils.logWarn('Invalid Adagio script found');
        w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY);
      }
    }
  } catch (err) {
    //
  }
}

jsencrypt

A Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis