# jsencrypt-ext

> A robust RSA extension for jsencrypt supporting segmented encryption and decryption for long messages. 一个强大的 jsencrypt RSA 扩展，支持长文本的 RSA 分段加密与 RSA 分段解密。

Latest version **3.4.1** (published 2026-02-27) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.4.1 |
| Published | 2026-02-27 |
| First published | 2021-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 155.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bartlian |
| Maintainers | bartlian |
| Keywords | rsa, jsencrypt, long-message, segmented-encryption, segmented-decryption, chunked-encryption, 分段加密, 分段解密, rsa分段加密, rsa分段解密 |

## Links

- npm: https://www.npmjs.com/package/jsencrypt-ext
- Repository: https://github.com/bartlian/jsencrypt-ext
- Homepage: https://github.com/bartlian/jsencrypt-ext#readme
- Issues: https://github.com/bartlian/jsencrypt-ext/issues
- npm.io page: https://npm.io/package/jsencrypt-ext

## Recent versions

- 3.4.1 (latest) — 2026-02-27
- 3.4.0 — 2026-02-27
- 3.3.0 — 2026-02-26
- 3.2.0 — 2026-02-26
- 3.1.0 — 2026-02-26
- 3.0.0 — 2026-02-25
- 2.1.2 — 2023-04-27
- 2.1.1 — 2023-04-27
- 2.1.0 — 2023-04-05
- 2.0.0 — 2023-04-05
- 1.1.1 — 2021-12-07
- 1.1.0 — 2021-12-07
- 1.0.5 — 2021-12-07
- 1.0.4 — 2021-12-06
- 1.0.3 — 2021-12-06
- … 3 more at https://npm.io/package/jsencrypt-ext/versions

## README

# jsencrypt-ext

[English](./README.md) | [中文](./README_zh.md)

**jsencrypt-ext** is a robust extension of the popular [jsencrypt](https://www.npmjs.com/package/jsencrypt) library. While RSA is technically not designed for long messages, many real-world business scenarios require it. This library provides a high-performance, cross-platform solution for **RSA chunked encryption and decryption**.

---

## ✨ Features

- **📦 Automatic Chunking**: Seamlessly encrypts and decrypts strings of any length by automatically calculating the maximum block size based on your RSA key bit length.
- **🛡️ UTF-8 Integrity**: Optimized for multi-byte characters. It ensures that characters like Chinese, Japanese, or Emojis are never "sliced" in half at chunk boundaries.
- **🚀 Cross-Platform**: Fully compatible with **Browsers**, **Node.js**, and **Mini-programs**.
- **💪 TypeScript First**: Built with TypeScript for excellent IDE autocompletion and type safety.

---

## 📦 Installation

```bash
# Using pnpm
pnpm add jsencrypt-ext

# Using npm
npm install jsencrypt-ext

```

---

## 🚀 Quick Start

```typescript
import JSEncryptExt from 'jsencrypt-ext'
// or
// import { JSEncryptExt } from 'jsencrypt-ext'

const longMessage =
  'This is a very long string that would normally exceed the RSA bit limit. ' +
  'jsencrypt-ext handles the chunking and concatenation automatically! 🚀'

// 1. Encryption
const encryptor = new JSEncryptExt()
encryptor.setPublicKey(`-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----`)
const ciphertext = encryptor.encrypt(longMessage)

// 2. Decryption
const decryptor = new JSEncryptExt()
decryptor.setPrivateKey(`-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----`)
const plaintext = decryptor.decrypt(ciphertext)
```

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