# rsasign

> JavaScript wrapper for native RSASSA-PKCS1-v1_5

Latest version **1.4.2** (published 2023-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install rsasign
pnpm add rsasign
yarn add rsasign
bun add rsasign
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.2 |
| Published | 2023-07-17 |
| First published | 2017-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 963.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Cyph, Inc. |
| Maintainers | cyphinc |
| Keywords | cryptography, post-quantum, rsa, asm.js |

## Links

- npm: https://www.npmjs.com/package/rsasign
- Repository: https://github.com/cyph/pqcrypto.js
- Homepage: https://github.com/cyph/pqcrypto.js#readme
- Issues: https://github.com/cyph/pqcrypto.js/issues
- npm.io page: https://npm.io/package/rsasign

## Dependencies (2)

- [sodiumutil](https://npm.io/package/sodiumutil.md) *
- [pem-jwk-norecompute](https://npm.io/package/pem-jwk-norecompute.md) *

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.4.2 (latest) — 2023-07-17
- 1.3.2-next (next) — 2019-09-09
- 1.4.1 — 2023-05-21
- 1.4.0 — 2023-03-27
- 1.3.8 — 2023-01-26
- 1.3.7 — 2022-08-06
- 1.3.6 — 2022-07-13
- 1.3.5 — 2022-07-12
- 1.3.4 — 2022-07-11
- 1.3.3 — 2021-03-23
- 1.3.2 — 2020-06-19
- 1.3.1 — 2019-11-20
- 1.3.1-next — 2019-09-09
- 1.3.0-next — 2019-09-09
- 1.2.0 — 2019-02-08
- … 16 more at https://npm.io/package/rsasign/versions

## README

# rsasign

## Overview

[RSASSA-PKCS1-v1_5](https://tools.ietf.org/html/rfc3447#section-8.2) with key length 2048 and
hash function [SHA-256](https://en.wikipedia.org/wiki/SHA-2) wrapped for usage in JavaScript.

The platform native RSA implementation (via
[SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) or the
[Node.js Crypto API](https://nodejs.org/api/crypto.html)) is preferred where available.
Otherwise, the OpenSSL implementation compiled to pure JavaScript with
[Emscripten](https://github.com/kripken/emscripten) is used as a fallback.

## Example Usage

	import {rsaSign} from 'rsasign';

	const keyPair /*: {privateKey: Uint8Array; publicKey: Uint8Array} */ =
		await rsaSign.keyPair()
	;

	const message /*: Uint8Array */ =
		new Uint8Array([104, 101, 108, 108, 111, 0]) // "hello"
	;

	/* Combined signatures */

	const signed /*: Uint8Array */ =
		await rsaSign.sign(message, keyPair.privateKey)
	;

	const verified /*: Uint8Array */ =
		await rsaSign.open(signed, keyPair.publicKey) // same as message
	;

	/* Detached signatures */

	const signature /*: Uint8Array */ =
		await rsaSign.signDetached(message, keyPair.privateKey)
	;

	const isValid /*: boolean */ =
		await rsaSign.verifyDetached(signature, message, keyPair.publicKey) // true
	;

	console.log(keyPair);
	console.log(message);
	console.log(signed);
	console.log(verified);
	console.log(signature);
	console.log(isValid);

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