1.0.6 • Published 4 years ago

jsencrypt_igor v1.0.6

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

Installing

Using npm:

$ npm install jsencrypt_igor

Example

// 公钥数据加密后向服务端发送
export const encryption = (str) => { 
  const encode = encodeURIComponent(JSON.stringify(str))
  const encrypt = new JsEncrypt()
  encrypt.setPublicKey(serverPubKey)
  const encyptRes = encrypt.encryptLong(encode)
  return btoa(encyptRes)
}
// 收到服务端数据后通过客户端私钥解密
export const decryption = (encrypted) => { 
  const decrypt = new JsEncrypt()
  decrypt.setPrivateKey(clientPriKey)
  const temp = decrypt.decryptLong(encrypted)
  return JSON.parse(decodeURIComponent(temp))
}
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago