https://github.com/nwtgck/aes128gcm-stream-npm
🛡128-bit AES-GCM Encryption Stream for Web Browsers
https://github.com/nwtgck/aes128gcm-stream-npm
aes-gcm browser encryption javascript security stream streams-api
Last synced: 6 months ago
JSON representation
🛡128-bit AES-GCM Encryption Stream for Web Browsers
- Host: GitHub
- URL: https://github.com/nwtgck/aes128gcm-stream-npm
- Owner: nwtgck
- License: mpl-2.0
- Created: 2019-04-21T04:28:36.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2023-03-02T08:57:16.000Z (over 2 years ago)
- Last Synced: 2024-10-11T15:09:10.176Z (about 1 year ago)
- Topics: aes-gcm, browser, encryption, javascript, security, stream, streams-api
- Language: TypeScript
- Homepage:
- Size: 690 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aes128gcm-stream
[](https://travis-ci.com/nwtgck/aes128gcm-stream-npm)128-bit AES-GCM Encryption Stream for Web Browsers
## Thanks for Firefox Send project
The original source code has come from [Firefox Send](https://send.firefox.com/), [mozilla/send](https://github.com/mozilla/send).
I appreciate that contributors created that streaming encryption feature, so I preserved the original contributors' commits which the project uses.## Installation
Install by npm from this GitHub repository
```bash
npm install -S git+https://github.com/nwtgck/aes128gcm-stream-npm#v0.1.3
```## Usage
Here is an usage in TypeScript.
You can remove the types and it will be available in **JavaScript** either.```ts
// TypeScript// Import
import {encryptStream, decryptStream} from 'aes128gcm-stream';
// Create a simple readable
// e.g. (await fetch("...")).body is ReadableStream
const readableStream: ReadableStream = ...
// Generate random key
const key: Uint8Array = crypto.getRandomValues(new Uint8Array(16));
// Encrypt
const encryptedStream: ReadableStream = encryptStream(
readableStream,
key,
);
// Decrypt
const decryptedStream: ReadableStream = decryptStream(
encryptedStream,
key
);
```