# blowfish-js

> Pure Javascript implementation of Blowfish block cipher.

Latest version **1.0.0** (published 2022-01-25) · GPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install blowfish-js
pnpm add blowfish-js
yarn add blowfish-js
bun add blowfish-js
```

## 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.0.0 |
| Published | 2022-01-25 |
| First published | 2022-01-25 |
| Weekly downloads | 0 |
| License | GPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 47.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Timo J. Rinne |
| Maintainers | rinne |
| Keywords | cipher, encryption, decryption, security, ECB, CBC, CFB, OFB |

## Links

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

## 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.0.0 (latest) — 2022-01-25

## README

In A Nutshell
=============

This is a pure Javascript implementation of Blowfish symmetric block
cipher algorithm.


Usage
=====

```
const blf = require('./blowfish.js');
const crypto = require('crypto');
{
	let key = crypto.randomBytes(32);
	let context = blf.key(key);
	let plaintext = 'Length is divisible by 8 to match the block size';
	let ciphertext = blf.ecb(context, Buffer.from(plaintext, 'utf8'));
	let decrypted = blf.ecb(context, ciphertext, true);
}
{
	let key = crypto.randomBytes(16);
	let iv = crypto.randomBytes(8);
	let context = blf.key(key);
	let plaintext = 'CBC mode also requires full blocks. Pad input data if necessary.';
	let ciphertext = blf.cbc(context, iv, Buffer.from(plaintext, 'utf8'));
	let decrypted = blf.cbc(context, iv, ciphertext, true);
}
{
	let key = crypto.randomBytes(16);
	let iv = crypto.randomBytes(8);
	let context = blf.key(key);
	let plaintext = 'Same with CFB. Full blocks only!';
	let ciphertext = blf.cfb(context, iv, Buffer.from(plaintext, 'utf8'));
	let decrypted = blf.cfb(context, iv, ciphertext, true);
}
{
	let key = crypto.randomBytes(16);
	let iv = crypto.randomBytes(8);
	let context = blf.key(key);
	let plaintext = 'With OFB, input length can be anything, but remember to use a unique IV every time! Encryption and decryption are identical in this mode.';
	let ciphertext = blf.ofb(context, iv, Buffer.from(plaintext, 'utf8'));
	let decrypted = blf.ofb(context, iv, ciphertext, true);
}
```


Compliance
==========

Test vectors are included into the package. Results of ecb, cbc, cfb,
and ofb functions are identical to nodejs crypto subsystem cipher
algorithms bf-ecb, bf-cbc, bf-cfb, and bf-ofb respectively.


Author
======

Timo J. Rinne <tri@iki.fi>


License
=======

GPL-2.0

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