Web Analytics

blowfish

⭐ 54 stars Japanese by egoroof

Blowfish

[![npm package][npm-badge]][npm]

[npm-badge]: https://img.shields.io/npm/v/egoroof-blowfish.svg?style=flat-square [npm]: https://www.npmjs.com/package/egoroof-blowfish

Blowfish>) はブラウザと Node.js 用の暗号化ライブラリです。

変更履歴は CHANGELOG.md を参照してください。

目次

インストール

最新バージョンは こちら から取得するか、npm で:

npm install egoroof-blowfish --save

JSモジュール

このライブラリはネイティブJSモジュールでのみ展開されるため、ブラウザではtypeがmodulescriptを使用する必要があります:

またはライブラリをコードにバンドルします。

Node.jsでは簡単にインポートできます:

import { Blowfish } from 'egoroof-blowfish';

使用法

キー、IV、平文、暗号文を含むすべての入力データは String または ArrayBuffer / Buffer である必要があります。 文字列は絵文字を含むすべてのユニコードをサポートします ✨。

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

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

Padding

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

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

戻り値の型

メソッド decode が返すべきデータの型:

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

--- Tranlated By Open Ai Tx | Last indexed: 2026-07-13 ---