Web Analytics

blowfish

⭐ 54 stars Spanish 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

Biblioteca de encriptación Blowfish>) para navegadores y Node.js.

Encuentra el registro de cambios en CHANGELOG.md

Tabla de Contenidos

Instalación

Obtén la última versión aquí o con npm:

npm install egoroof-blowfish --save

Módulos JS

La biblioteca solo se implementa en módulos JS nativos, por lo que en los navegadores debes usar script con tipo module:

O agrupe la biblioteca con su código.

En Nodejs se importa fácilmente:

import { Blowfish } from 'egoroof-blowfish';

Uso

Todos los datos de entrada, incluyendo la clave, IV, texto plano y texto cifrado, deben ser un String o ArrayBuffer / Buffer. Los strings soportan todo unicode incluyendo emoji ✨.

Ejemplo

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

Tipo de retorno

Qué tipo de datos debe devolver el método decode:

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

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