@altcha/crypto

中文文档
0.0.2发布于 2025/04/30MITTypeScriptESM + CJS零依赖近 30 天下载 16.7万

A lightweight library simplifying asymmetric data encryption using Web Crypto

原始使用文档
文档目录5 节
  1. Features
  2. Compatibility
  3. Usage
  4. API
  5. License

ALTCHA JS Crypto Library

A lightweight library simplifying asymmetric data encryption using Web Crypto. It employs a hybrid approach combining RSA keys and AES encryption for enhanced security.

Features

  • Simplified hybrid encryption using RSA + AES
  • Compatible with all modern browsers supporting Web Crypto
  • Supports node.js streams, facilitating encryption of large files

Compatibility

  • Node.js 20+
  • Bun 1+
  • Deno 1+
  • Modern browsers

Usage

import { cipher, rsa } from '@altcha/crypto';

const keyPair = await rsa.generateKeyPair();

const encrypted = await cipher.encrypt(keyPair.publicKey, new TextEncoder().encode('Hello World'));

const decrypted = await cipher.decrypt(keyPair.privateKey, encrypted);

Node.js streams:

import { createReadStream, createWriteStream } from 'node:fs';
import { nodeCipher, rsa } from '@altcha/crypto';

const keyPair = await rsa.generateKeyPair();

await nodeCipher.encryptStream(keyPair.publicKey, createReadStream('./input.txt'), createWriteStream('./output.txt.enc'));

API

TODO

License

MIT

版本与发布记录

@altcha/crypto 共发布 2 个版本,首次发布于 2024/04/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.2latest2025/04/301.5 年前
0.0.12024/04/072 年前

关于 @altcha/crypto 的常见问题

@altcha/crypto 是什么?

A lightweight library simplifying asymmetric data encryption using Web Crypto

如何安装 @altcha/crypto?

在项目目录运行 npm install @altcha/crypto,或使用 pnpm add / yarn add / bun add。

@altcha/crypto 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@altcha/crypto 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@altcha/crypto 可以商用吗?

@altcha/crypto 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@altcha/crypto 的下载量有多少?

根据 npm 官方下载统计,@altcha/crypto 在 2026/10/06 – 2026/11/04 这 30 天内被下载 167,367 次,日均约 5,579 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@altcha/crypto 还在维护吗?

最新版本 0.0.2 发布于 2025/04/30(1.5 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/04/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。