ddn.crypto.legacy.cipher.blowfish
Blowfish Block Cipher.
WARNING: DEPRECATED ALGORITHM
Blowfish is deprecated due to its 64-bit block size (vulnerable to birthday attacks). Use AES-256 for new encryption.
Standards
Schneier's Blowfish specification
Copyright
Copyright © 2025, Dejan Lekić
License
BSD-3-Clause
Types 1
classBlowfish : BlockCipher
Blowfish block cipher implementation (Schneier's specification).
DEPRECATED: Do not use for new encryption.
Blowfish encrypts 64-bit blocks using a variable-length key from 32 to 448 bits (4 to 56 bytes). This implementation is provided for legacy compatibility only.
Example:
auto bf = new Blowfish(key); // 4-56 byte key
ubyte[8] ciphertext;
bf.encrypt(plaintext, ciphertext);Fields
private uint[18] _Pprivate uint[256][4] _SMethods
size_t blockSize() @property const @safe pure nothrow @nogcReturns: The block size in bytes (always 8 for Blowfish).void encrypt(const(ubyte)[] input, ubyte[] output)Encrypts a single 8-byte block.void decrypt(const(ubyte)[] input, ubyte[] output)Decrypts a single 8-byte block.private
void encryptBlock(ref uint left, ref uint right)Encrypts a block using the 16-round Feistel network.private
void decryptBlock(ref uint left, ref uint right)Decrypts a block using the 16-round Feistel network in reverse.private
uint bytesToUint(const(ubyte)[] bytes) static @safe pure nothrow @nogcConverts 4 bytes to a big-endian 32-bit unsigned integer.private
void uintToBytes(uint value, ubyte[] bytes) static @safe pure nothrow @nogcConverts a 32-bit unsigned integer to 4 big-endian bytes.Constructors
this(const(ubyte)[] key)Constructs a Blowfish cipher with the given key.Variables 2
private var
uint[18] INIT_Pprivate var
uint[256][4] INIT_S