How to use jsencrypt - 10 common examples

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 fengcms / python-learn-demo / news / fe-manage / src / tool / rsa.js View on Github external
export default str => {
  let encrypt = new JSEncrypt()
  encrypt.setPublicKey(key)
  // console.log(str)
  return encrypt.encrypt(str)
}
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) {
    //
  }
}
github lsqswl / rsaencrypt / lib / index.js View on Github external
function encryptPublicLong(text, publicKey) {
    var rsa = new jsencrypt_1["default"]();
    rsa.setPublicKey(publicKey);
    var key = rsa.getKey();
    var ct = "";
    // RSA每次加密117bytes,需要辅助方法判断字符串截取位置
    // 1.获取字符串截取点
    var bytes = new Array();
    bytes.push(0);
    var byteNo = 0;
    var len = text.length;
    var c;
    var temp = 0;
    for (var i = 0; i < len; i++) {
        c = text.charCodeAt(i);
        if (c >= 0x010000 && c <= 0x10FFFF) { // 特殊字符,如Ř,Ţ
            byteNo += 4;
        }
github lazyboyl / bg-admin / bg-admin-web / src / main.js View on Github external
Vue.prototype.$encruption = function (obj) {
  let encrypt = new JsEncrypt();
  encrypt.setPublicKey(
    `-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDyKmfJhgAHEK0Yo6qOtFB8sSfYIZBJUyyXi1X7EgkZo3kmMOu6/uT7SwC9EnqbiMySJfAlvB200ZMIk6e1NQrPLZpc5VSuzSQ3NqdXOdbNnhXAUeME8IcsbscK9XP8BxldMhUhIK+3zovI1VCY2kLO6TMwEVvTdH+F1jW/WFkplwIDAQAB-----END PUBLIC KEY-----`
  )
  return encrypt.encrypt(obj);
};
github datash / datash / src / client / encryption / index.js View on Github external
export const decryptAsymmetric = (privateKey, encryptedText) => {
  const crypt = new JSEncrypt();
  crypt.setPrivateKey(privateKey);
  return crypt.decrypt(encryptedText);
};
github Chenwe-i-lin / KnowledgeFruits / manager / src / pages / register / register.vue View on Github external
encrypt(publicKey, password) {
      var en = new JSEncrypt();
      en.setPublicKey(publicKey);
      return en.encrypt(password);
    },
    verify() {
github datash / datash / src / client / encryption / index.js View on Github external
export const encryptAsymmetric = (publicKey, actualText) => {
  const crypt = new JSEncrypt();
  crypt.setPublicKey(publicKey);
  return crypt.encrypt(actualText);
};
github datash / datash / src / client / encryption / index.js View on Github external
export const generateAsymmetricKeyPair = (keySize = 1024) => {
  const crypt = new JSEncrypt({ default_key_size: keySize });
  const keys = crypt.getKey();
  return {
    privateKey: keys.getPrivateKey(),
    publicKey: keys.getPublicKey()
  };
};

jsencrypt

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

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis