title: DES encrypt but Fortify report Weak Encryption on PHP 5.5.22
body: <p>I want to DES encrypt and decrypt, but Fortify report say they are Weak Encryption
  how can I solve this problem?</p>
  
  <p>encrypt</p>
  
  <pre><code>    function encrypt($key, $encrypt)
      {   
          $size = mcrypt_get_block_size(MCRYPT_DES, MCRYPT_MODE_CBC);
          $pad = $size - (strlen($encrypt) % $size);
          $encrypt = $encrypt . str_repeat(chr($pad), $pad);
          $data = mcrypt_encrypt(MCRYPT_DES, $key, $encrypt, MCRYPT_MODE_CBC, $key);
  
          return base64_encode($data);
      }
  </code></pre>
  
  <p>decrypt</p>
  
  <pre><code>    function decrypt($key, $decrypt)
      {
          $decrypt = base64_decode($decrypt);
          $decrypt = mcrypt_decrypt(MCRYPT_DES, $key, $decrypt, MCRYPT_MODE_CBC, $key);
          $pad = ord($decrypt{strlen($decrypt) - 1});
  
          if ($pad &gt; strlen($decrypt)) {
              return false;
          }
  
          if (strspn($decrypt, chr($pad), strlen($decrypt) - $pad) != $pad) {
              return false;
          }
  
          return substr($decrypt, 0, -1 * $pad);
      }
  </code></pre>
  
  <p>report
  IssueGroup  Weak Encryption</p>
  
  <pre><code>    }
  
      $size = mcrypt_get_block_size(MCRYPT_DES, MCRYPT_MODE_CBC);
      $pad = $size - (strlen($encrypt) % $size);
      $encrypt = $encrypt . str_repeat(chr($pad), $pad);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>    {
          $decrypt = base64_decode($decrypt);
          $decrypt = mcrypt_decrypt(MCRYPT_DES, $key, $decrypt, MCRYPT_MODE_CBC, $key);
          $pad = ord($decrypt{strlen($decrypt) - 1});
  </code></pre>