-1

I am using codeigniter 2x, and I need to decode string I have been given, and that string containes array. For that I got a key, iv, cipher and mode.

I figure out how to set key, cipher and mode:

$this->load->library('encrypt');
$this->encrypt->set_cipher(MCRYPT_RIJNDAEL_128);
$this->encrypt->set_mode(MCRYPT_MODE_CBC);
$key = 'mysomekey';

But I can't figure out how to use iv I have been give, and decode that string.

On net I did found only this:

$o = $this->encrypt->decode($o,$key);

Can anyone helps me?

Sasa
  • 553
  • 7
  • 25

1 Answers1

0

From the mcrypt docs you can provide all the input parameters in the decrypt call:

string mcrypt_decrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] )

It is best not to use mcrypt, it is abandonware, has not been updated in years and does not support standard PKCS#7 padding, only non-standard null padding that can't even be used with binary data.

Codeigniter provides it's own Encryption Class.

Also consider using defuse, it is being maintained and is correct.

zaph
  • 111,848
  • 21
  • 189
  • 228
  • I have some requirements I have to achive, that's why I am using mcrypt. I saw this but doesn't work. And I have to write as codeigniter sintax using library also. – Sasa Mar 13 '16 at 12:28