# egoroof-blowfish

> Blowfish encryption library for browsers and Node.js

Latest version **4.0.3** (published 2026-07-17) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2026-07-17 |
| First published | 2017-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 56 |
| Author | egoroof |
| Maintainers | egoroof |
| Keywords | blowfish, cbc, cipher, decryption, ecb, encryption, library |

## Links

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

## 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

- 4.0.3 (latest) — 2026-07-17
- 4.0.2 — 2025-08-26
- 4.0.1 — 2023-06-10
- 4.0.0 — 2023-06-03
- 3.0.0 — 2023-04-16
- 2.2.2 — 2020-03-07
- 2.2.1 — 2019-12-29
- 2.2.0 — 2019-05-19
- 2.1.0 — 2018-01-06
- 2.0.0 — 2017-11-24
- 1.0.1 — 2017-02-25
- 1.0.0 — 2017-02-19
- 0.1.0 — 2017-01-08

## README

# Blowfish

[Blowfish](<https://en.wikipedia.org/wiki/Blowfish_(cipher)>) encryption library for browsers and Node.js.

Find the changelog in [CHANGELOG.md](https://github.com/egoroof/blowfish/blob/master/CHANGELOG.md)

## Table of Contents

- [Installation](#installation)
  - [JS modules](#js-modules)
- [Usage](#usage)
  - [Example](#example)
  - [Block cipher mode of operation](#block-cipher-mode-of-operation)
  - [Padding](#padding)
  - [Return type](#return-type)

## Installation

Take latest version [here](https://unpkg.com/egoroof-blowfish) or with [npm](https://www.npmjs.com/package/egoroof-blowfish):

```
npm install egoroof-blowfish --save
```

### JS modules

The library is only deployed in [native JS modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), so in browsers you have to use `script` with type `module`:

```html
<script type="module">
  import { Blowfish } from 'https://your-host/blowfish.mjs';
  // your code here..
</script>
```

Or bundle the library to your code.

In Nodejs it imports easily:

```js
import { Blowfish } from 'egoroof-blowfish';
```

## Usage

All input data including key, IV, plaintext and ciphertext should be a `String` or `ArrayBuffer` / `Buffer`.
Strings support all unicode including emoji ✨.

### Example

```js
import { Blowfish } from 'egoroof-blowfish';

const bf = new Blowfish('super key', Blowfish.MODE.ECB, Blowfish.PADDING.NULL); // only key isn't optional
bf.setIv('abcdefgh'); // optional for ECB mode; bytes length should be equal 8

const encoded = bf.encode('input text even with emoji 🎅');
const decoded = bf.decode(encoded, Blowfish.TYPE.STRING); // type is optional
```

### Block cipher mode of operation

https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation

```js
Blowfish.MODE.ECB; // (default) Electronic Codebook
Blowfish.MODE.CBC; // Cipher Block Chaining
```

### Padding

http://www.di-mgt.com.au/cryptopad.html

```js
Blowfish.PADDING.PKCS5; // (default) Pad with bytes all of the same value as the number of padding bytes
Blowfish.PADDING.ONE_AND_ZEROS; // Pad with 0x80 followed by zero bytes
Blowfish.PADDING.LAST_BYTE; // Pad with zeroes except make the last byte equal to the number of padding bytes
Blowfish.PADDING.NULL; // Pad with zero (null) characters
Blowfish.PADDING.SPACES; // Pad with spaces
```

### Return type

Which type of data should return method `decode`:

```js
Blowfish.TYPE.STRING; // (default) String
Blowfish.TYPE.UINT8_ARRAY; // Uint8Array
```

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