travist / jsencrypt

A zero-dependency Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.
http://www.travistidwell.com/jsencrypt
Other
6.69k stars 2.02k forks source link

An error occurred when using jsencrypt in a lower version of Chrome #295

Open wrh8214158 opened 1 year ago

wrh8214158 commented 1 year ago

chrome version: 17 jsencrypt version: 3.3.2

I have tried installing all versions of jsencrypt, but still reported an error.

use like this:

export const rsaEncrypt = (val: Record<string, unknown> | unknown[] | string | number = '') => {
  const PUBLIC_KEY = `sdwdwadwadwdsasdwadwdwadawdawdwadwad`;
  const encrypt = new JSEncrypt();
  encrypt.setPublicKey(PUBLIC_KEY);
  const value =
    typeof val === 'object'
      ? JSON.stringify(val)
      : ['string', 'number'].includes(typeof val)
      ? String(val)
      : '';
  return encrypt.encrypt(value);
};

error: image