开发者

How can you override the 24 character mcrypt salt limit?

开发者 https://www.devze.com 2023-03-03 13:46 出处:网络
I would like to use a salt that has more than 24 characters with mcrypt. mcrypt_encrypt(MCRYPT_RIJNDA开发者_如何学JAVAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT

I would like to use a salt that has more than 24 characters with mcrypt.

mcrypt_encrypt(MCRYPT_RIJNDA开发者_如何学JAVAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND));

However if I make $salt greater than 24 characters it throws this warning and uses a truncated salt at 24 characters:

Warning: mcrypt_encrypt() [function.mcrypt-encrypt]: Size of key is too large for this algorithm

Is there any way to get around this?


24 is the limit of this alorithm. Chars over 24 characters isn't used. But you can always trasnform your salt.

http://en.wikipedia.org/wiki/Advanced_Encryption_Standard


I would personally MD5 the salt and use that otherwise you need to select a different algorithm.

0

精彩评论

暂无评论...
验证码 换一张
取 消