Skip to content

Oxrial/jsencrypt-oxr

 
 

Repository files navigation

Introductio

A forked from jsencrypt and jsencrypt-ext,support for privateKey encrypt,publicKey decrypt and long plaintext.

PrivateKey encrypt and PublicKey decrypt

const encrypt = new JSEncrypt()
encrypt.setPrivateKey(privateKey)
const encrypted = encrypt.encrypt("test", { by: "PrivateKey", encoding: "UTF8" })
console.log("私钥加密 encrypted:", encrypted)

const dencrypt = new JSEncrypt()
dencrypt.setPublicKey(publicKey)
const dencrypted = dencrypt.decrypt(encrypted as string, { by: "PublicKey" })
console.log("公钥解密 dencrypted:", dencrypted)

扩充 API

function(args) options: IEncryptEncodingOptions =
{ encoding?: "ASCII" |"UTF8"; by?: "PrivateKey" |"PublicKey"; }
desc
encrypt(str, options) default = { encoding: "UTF8", by: "PublicKey" } 公钥(d)/私钥 加密
decrypt(str, options) default = { by: "PrivateKey" } 私钥(d)/公钥 解密

Long Plaintext

const encrypt = new JSEncrypt()
encrypt.setPublicKey(publicKey)
const longMessage = JSON.stringify(
  Array.from(new Array(100))
    .fill("壹贰叁肆伍陆柒捌玖拾佰仟")
    .map((i, index) => ({ name: `${index}${i}` }))
)
const encrypted = encrypt.encryptExt(longMessage)
console.log("公钥加密 encrypted:", encrypted)

const dencrypt = new JSEncrypt()
dencrypt.setPrivateKey(privateKey)
const dencrypted = dencrypt.decryptExt(encrypted as string)
console.log("私钥解密 dencrypted:", dencrypted)

扩充 API

function(args) options: IEncryptEncodingOptions =
{ encoding?: "ASCII" |"UTF8"; by?: "PrivateKey" |"PublicKey"; }
description
encryptOxr(str, options) default = { encoding: "UTF8", by: "PublicKey" } 公钥(d)/私钥 加密
decryptOxr(str, options) default = { by: "PrivateKey" } 私钥(d)/公钥 解密

About

A forked from travist/jsencrypt,support for privateKey encrypt,publicKey decrypt and long plaintext

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 58.0%
  • TypeScript 41.2%
  • Other 0.8%