1.4.2 • Published 10 months ago

rsasign v1.4.2

Weekly downloads
40
License
MIT
Repository
github
Last release
10 months ago

rsasign

Overview

RSASSA-PKCS1-v1_5 with key length 2048 and hash function SHA-256 wrapped for usage in JavaScript.

The platform native RSA implementation (via SubtleCrypto or the Node.js Crypto API) is preferred where available. Otherwise, the OpenSSL implementation compiled to pure JavaScript with 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);
1.4.2

10 months ago

1.4.1

12 months ago

1.4.0

1 year ago

1.3.8

1 year ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.2-next

5 years ago

1.3.1-next

5 years ago

1.3.0-next

5 years ago

1.2.0

5 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago