title: Encryption String with Session Key in c#
body: <p>I want to encrypt <code>String</code> with <code>SessionKey</code>. Below is sample code I am using, but I am not getting the correct encrypted answer.</p>
  
  <pre><code>string = test;
  SessionKey = "ThisIsASecretKey";
  </code></pre>
  
  <p>For encryption, I am using the method below:</p>
  
  <pre><code> byte[] array = Encoding.ASCII.GetBytes("ThisIsASecretKey");
  
           byte[] array1 = Encoding.ASCII.GetBytes("test");
           byte[] reult = encryptUsingSessionKey(array, array1);
  
   public byte[] encryptUsingSessionKey(byte[] skey,byte[] data)
      {
          Org.BouncyCastle.Crypto.Paddings.PaddedBufferedBlockCipher cipher = new Org.BouncyCastle.Crypto.Paddings.PaddedBufferedBlockCipher(new AesEngine(), new Pkcs7Padding());
  
          cipher.Init(true, new Org.BouncyCastle.Crypto.Parameters.KeyParameter(skey));
  
          int outputSize = cipher.GetOutputSize(data.Length);
  
          byte[] tempOP = new byte[outputSize];
          int processLen = cipher.ProcessBytes(data, 0, data.Length, tempOP, 0);
          int outputLen = cipher.DoFinal(tempOP, processLen);
  
          byte[] result = new byte[processLen + outputLen];
  
          tempOP.CopyTo(result, 0);
         // tempOP.CopyTo(tempOP,0,result,0,result.Length);
          return result;
      }
  </code></pre>
  
  <p>After encryption, I am getting </p>
  
  <pre><code>jZî|ðçê`u0aC
  </code></pre>
  
  <p>but the correct answer would be </p>
  
  <pre><code>ƒ_jZî|ðç_ê‹\`u0aC
  </code></pre>