title: Encryption using Rijndael AES using 128 bit keys, 16 byte blocks and cipher block chaining
body: <p>In our project, I must use the Algorithm AES 128 CBC with the following data:</p>
  
  <p>KEY = "abcdef0123456789abcdef0123456789"</p>
  
  <p>IV = "00000000000000000000000000000000"</p>
  
  <p>The text to encryt is</p>
  
  <p>2~1~000024~0910~20130723092446~T~00002000~USD~F~375019001012120~0~0~00000000000~</p>
  
  <p>The result expected is</p>
  
  <p>0D 58 35 AF EB EE 04 C6 DC 24 21 53 8D B7 C3 8A 12 83 97 0E B3 1F 21 A4 7D 2E 3C C6 23 D2 9E F0 46 12 79 C7 AC F9 3B 03 1B E2 B6 9C E4 5C 93 39 55 49 57 F2 9E F6 09 F0 19 EE C9 75 98 3A 03 B5 37 62 2D 7E 0F 19 6B E1 48 F1 C7 CB B8 8E 60 2A</p>
  
  <p>The result text's length is 160 characters.</p>
  
  <p>I tried using many algorithms but all my results are different.</p>
  
  <p>would you encrypt the text with your own method and you validate with the expected result?</p>
  
  <p>Would you paste your results?</p>
  
  <p>This is my test:</p>
  
  <pre><code>$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
  
  $data_to_encrypt = "2~1~000024~0910~20130723092446~T~00002000~USD~F~375019001012120~0~0~00000000000~";
  $key128 = "abcdef0123456789abcdef0123456789";
  $iv = "0000000000000000"."0000000000000000";
  
  echo "data_to_encrypt: ".$data_to_encrypt."&lt;br/&gt;";
  
  if (($res = mcrypt_generic_init($cipher, $key128, $iv)) != -1)
  {
      // PHP pads with NULL bytes if $cleartext is not a multiple of the block size.
      $cipherText = mcrypt_generic($cipher,$data_to_encrypt);
      mcrypt_generic_deinit($cipher);
      $data_encrypted = strtoupper(bin2hex($cipherText));
      echo "result encrypt: ".$data_encrypted."&lt;br/&gt;";
      echo "len: ".strlen($data_encrypted)."&lt;br/&gt;";
  }
  </code></pre>
  
  <p>This is my answer:</p>
  
  <p>data_to_encrypt: 2~1~000024~0910~20130723092446~T~00002000~USD~F~375019001012120~0~0~00000000000~
  result encrypt: C9A4E600BAC6FC4F2077FF62DDB5F9BEAB1C9C567A98E6B81373711A4BC0FFE1748F5E26886896AB87CD375567C5466E6A9F4C079AD19B592E080896BCFDB52324F342A9F94AE71FADB1F6820EB57F7B
  len: 160</p>
  
  <p>Thanks in advance for your help and time.</p>