# aes256

> A Node.js module to simplify using the built-in "crypto" module for AES256 encryption with random initialization vectors

Latest version **1.1.0** (published 2021-02-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-02-06 |
| First published | 2015-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 50 |
| Author | James M. Greene |
| Maintainers | jamesmgreene |
| Keywords | aes, aes256, iv, initialization, vector, encryption, cryptography |

## Links

- npm: https://www.npmjs.com/package/aes256
- Repository: https://github.com/JamesMGreene/node-aes256
- Homepage: https://github.com/JamesMGreene/node-aes256#readme
- Issues: https://github.com/JamesMGreene/node-aes256/issues
- npm.io page: https://npm.io/package/aes256

## 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.1.0 (latest) — 2021-02-06
- 1.0.4 — 2018-08-10
- 1.0.3 — 2018-01-12
- 1.0.2 — 2015-12-18
- 1.0.1 — 2015-12-17
- 1.0.0 — 2015-12-17

## README

# aes256
[![GitHub Latest Release](https://badge.fury.io/gh/JamesMGreene%2Fnode-aes256.svg)](https://github.com/JamesMGreene/node-aes256) [![Build Status](https://secure.travis-ci.org/JamesMGreene/node-aes256.svg?branch=master)](https://travis-ci.org/JamesMGreene/node-aes256) [![Coverage Status](https://coveralls.io/repos/JamesMGreene/node-aes256/badge.svg?branch=master&service=github)](https://coveralls.io/github/JamesMGreene/node-aes256?branch=master) [![Dependency Status](https://david-dm.org/JamesMGreene/node-aes256.svg?theme=shields.io)](https://david-dm.org/JamesMGreene/node-aes256) [![Dev Dependency Status](https://david-dm.org/JamesMGreene/node-aes256/dev-status.svg?theme=shields.io)](https://david-dm.org/JamesMGreene/node-aes256#info=devDependencies)


A Node.js module to simplify using the built-in `crypto` module for AES-256 encryption with random initialization vectors.

This module generates a random [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector) each time one of the `encrypt` methods is called.

Furthermore, your symmetric session key (a.k.a. secret, a.k.a. passphrase) can be of any size because it is hashed using SHA-256.


## Install

```shell
$ npm install aes256
```


## Usage

### Example using static methods

```js
var aes256 = require('aes256');

var key = 'my passphrase';
var plaintext = 'my plaintext message';
var buffer = Buffer.from(plaintext);

var encryptedPlainText = aes256.encrypt(key, plaintext);
var decryptedPlainText = aes256.decrypt(key, encryptedPlainText);
// plaintext === decryptedPlainText

var encryptedBuffer = aes256.encrypt(key, buffer);
var decryptedBuffer = aes256.decrypt(key, encryptedBuffer);
// plaintext === decryptedBuffer.toString('utf8)
```


### Example using an `AesCipher` instance

```js
var aes256 = require('aes256');

var key = 'my passphrase';
var plaintext = 'my plaintext message';
var buffer = Buffer.from(plaintext);

var cipher = aes256.createCipher(key);

var encryptedPlainText = cipher.encrypt(plaintext);
var decryptedPlainText = cipher.decrypt(encryptedPlainText);
// plaintext === decryptedPlainText

var encryptedBuffer = cipher.encrypt(buffer);
var decryptedBuffer = cipher.decrypt(encryptedBuffer);
// plaintext === decryptedBuffer.toString('utf8)
```


#### API

_Documentation maaaaaybe forthcoming...._

For now, looking at the above usage examples, the code, or the unit tests should all give you a pretty good idea without much effort as the API surface area is very small.


## License

Copyright (c) 2015-2021, James M. Greene (MIT License)

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