title: C# and Java DES Encryption value are not identical
body: <p>I am trying to encrypt the same data using C# and Java. If the data is more than 7 bytes then Java and C#'s encrypted value are not identical.</p>
  <ul>
  <li><p>Input 1: <strong>a</strong><br />
  java output: <em>FrOzOp/2Io8=</em><br />
  C#   output: <em>FrOzOp/2Io8=</em></p>
  </li>
  <li><p>Input 2: <strong>abc</strong><br />
  j : <em>H9A/ahl8K7I=</em><br />
  c#: <em>H9A/ahl8K7I=</em></p>
  </li>
  <li><p>Input 3: <strong>aaaaaaaa</strong>  (<strong>Problem</strong>)<br />
  j : <em>Gxl7e0aWPd7j6l7uIEuMxA==</em><br />
  c#: <em>Gxl7e0aWPd7sf1xR6hK4VQ==</em></p>
  </li>
  </ul>
  <p>Here is the implementation of C# and Java methods.<br />
  C# code:</p>
  <pre><code>public String saltTxt = &quot;12345678&quot;;
  public String Encrypt(String txt)
  {
          byte[] data = Encrypt(Encoding.UTF8.GetBytes(txt));
          
          DESCryptoServiceProvider alg = new DESCryptoServiceProvider();
  
          alg.Key = Encoding.UTF8.GetBytes(saltTxt.ToCharArray(), 0, cprovider.KeySize / 8);
          alg.IV = new byte[8];
  
          MemoryStream ms = new MemoryStream();
          CryptoStream stem = new CryptoStream( ms, cprovider.CreateEncryptor(),CryptoStreamMode.Write);
  
          stem.Write(txt, 0, txt.Length);
          stem.FlushFinalBlock();
  
          data = ms.ToArray();
          
          return Convert.ToBase64String(data);
   }
  </code></pre>
  <p>Java Code:</p>
  <pre><code>public String saltTxt = &quot;12345678&quot;;
  public String Encrypt(String str) {
      try {
          KeySpec myKey = new DESKeySpec(saltTxt.getBytes(&quot;UTF8&quot;));
          SecretKey key = SecretKeyFactory.getInstance(&quot;DES&quot;).generateSecret(myKey);
          Cipher ecipher = Cipher.getInstance(&quot;DES&quot;);
          ecipher.init(Cipher.ENCRYPT_MODE, key);
  
          byte[] data = str.getBytes(&quot;UTF8&quot;);
  
          byte[] crypt = ecipher.doFinal(data);
          
          return new BASE64Encoder().encode(crypt);
      } catch (Exception ex) {
      }
  
      return null;
  } 
  </code></pre>
  <p>Any idea why it's not working as expected?</p>