title: AES 256 encryption PHP with Padding
body: <p>I got the following requirements for the encryption for the API i am currently trying to access:</p>
  
  <ul>
  <li>PKCS7 padding method</li>
  <li>CBC encryption mode</li>
  <li>AES key size 256, block size 128</li>
  </ul>
  
  <p>Everytime i submit to the API with the encryption, there seems to be something wrong with the API (unfortunately no error is produced).</p>
  
  <pre><code>$Data = "GOOD!";
  $aesKey = "1234567812345678";
  
  $EncryptedData = encrypt($aesKey,$Data);
  $DecryptedData = decrypt($aesKey,$EncryptedData);
  
  echo "Orignal Data : ". $Data;
  echo "&lt;br/&gt;";
  echo "After encryption = ". $EncryptedData;
  echo "&lt;br/&gt;";
  echo "After decryption = " .$DecryptedData;
  
  function encrypt($aesKey, $dataToEncrypt) {
      $output = false;
      $iv = '{{{{{{{{{{{{{{{{';
      $output = openssl_encrypt($dataToEncrypt, 'AES-128-CBC', $aesKey,
      OPENSSL_RAW_DATA, $iv);
      $output = base64_encode($output);
      return $output;
  }
  
  function decrypt($aesKey, $dataTodecrypt) {
      $output = false;
      $iv = '{{{{{{{{{{{{{{{{';
      $dataTodecrypt = base64_decode ($dataTodecrypt);
      $dataTodecrypt = $output = openssl_decrypt($dataTodecrypt, 'AES-128-CBC',
      $aesKey, OPENSSL_RAW_DATA, $iv);
      return $output;
  }
  </code></pre>
  
  <p>Questions:</p>
  
  <ul>
  <li>What exactly is PKCS7 padding method and can be implemented with php?</li>
  <li>AES 256 is fine but what exactly does block size mean?</li>
  <li>What exactly does IV do?</li>
  </ul>