4

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

mcrypt_encrypt(MCRYPT_RIJNDAEL_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?

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
Andrew Jenkins
  • 1,590
  • 13
  • 16
  • You shouldn't "like" to do things that are out of the inner workings of the encryption algorithm. – N.B. May 08 '11 at 13:03

2 Answers2

3

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

Marcin
  • 1,429
  • 8
  • 16
0

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

Kmaid
  • 169
  • 2
  • 8