Blowfish is a fast block cipher proposed by B.Schneier in 1994. It processes data by blocks of 64 bits (8 bytes), and supports keys of 32 to 448 bits.
The small block size (64 bits) of Blowfish opens the way to some collision-based attacks. Depending on the application, ciphers with larger block size should be preferred.
The string argument is the key; its length must be between 4 and 56.
The direction argument specifies whether encryption or decryption is to be performed.
The optional mode
argument specifies a chaining mode, as described above; CBC
is used by default.
The optional pad
argument specifies a padding scheme to pad cleartext to an integral number of blocks. If no pad
argument is given, no padding is performed and the length of the cleartext must be an integral number of blocks.
The optional iv
argument is the initialization vector used by the chaining mode. It is ignored in ECB mode. If provided, it must be a string of the same size as the block size (8 bytes). If omitted, the null initialization vector (8 zero bytes) is used.
The blowfish
function returns a transform that performs encryption or decryption, depending on the direction argument.