how long is the default key size used by mcrypt_bl

2019-06-09 02:49发布

问题:

I'm going to use Blowfish cipher for my project in PHP (mcrypt_blowfish). But I have a question regarding the used of mcrypt_blowfish, how long is the deafult key size that was used by this mode of encryption in PHP?? Some other cipher that was support by libmcrypt had a declared key size, like :

 MCRYPT_RIJNDAEL_128 --> 128 bit key

 MCRYPT_RIJNDAEL_192 --> 192 bit key

 MCRYPT_RC6_128 --> 128 bit key

 MCRYPT_RC6_192 --> 192 bit key

But how long is the deafult key size for mcrypt_blowfish?? Thx before...

回答1:

It seems to use a variable key size (it seems there isn't a "default" size) :

http://en.wikipedia.org/wiki/Blowfish_(cipher)

"Blowfish has a 64-bit block size and a variable key length from 32 bits up to 448 bits"

Here is an example using a 448 bits key : http://www.php.net/manual/en/function.mcrypt-encrypt.php#96635

Looking on other sites, MCRYPT_BLOWFISH_128, MCRYPT_BLOWFISH_192, MCRYPT_BLOWFISH_256 and MCRYPT_BLOWFISH_448 should work too (didn't try ^^)