# jsencrypt-oxr

> A based from travist/jsencrypt@3.3.1 and bartlian/jsencrypt-ext，support for privateKey encrypt，publicKey decrypt and long plaintext.

Latest version **1.0.1** (published 2023-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsencrypt-oxr
pnpm add jsencrypt-oxr
yarn add jsencrypt-oxr
bun add jsencrypt-oxr
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-07-05 |
| First published | 2023-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 884.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Oxrial |
| Maintainers | oxrial |

## Links

- npm: https://www.npmjs.com/package/jsencrypt-oxr
- Repository: https://github.com/Oxrial/jsencrypt-oxr
- Homepage: https://github.com/Oxrial/jsencrypt-oxr.git
- Issues: https://github.com/Oxrial/jsencrypt-oxr/issues
- npm.io page: https://npm.io/package/jsencrypt-oxr

## Recent versions

- 1.0.1 (latest) — 2023-07-05
- 1.0.0 — 2023-07-05

## README

## Introductio

A forked from [jsencrypt](https://www.npmjs.com/package/jsencrypt) and [jsencrypt-ext](https://www.npmjs.com/package/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 = <br/> { 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 = <br/> { encoding?: "ASCII" \|"UTF8"; by?: "PrivateKey" \|"PublicKey"; } | description       |
| ------------------------ | ---------------------------------------------------------------------------------------------------------- | ----------------- |
| encryptOxr(str, options) | default = { encoding: "_UTF8_", by: "_PublicKey_" }                                                        | 公钥(d)/私钥 加密 |
| decryptOxr(str, options) | default = { by: "_PrivateKey_" }                                                                           | 私钥(d)/公钥 解密 |

---
_Source: https://npm.io/package/jsencrypt-oxr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
