public override void Write(byte[] buffer, int offset, int count)
        {
            if (_mode == CryptoMode.Decrypt)
            {
                throw new NotSupportedException("This stream does not Decrypt via Write()");
            }

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            // workitem 7696
            if (count == 0)
            {
                return;
            }

            byte[] plaintext = null;
            if (offset != 0)
            {
                plaintext = new byte[count];
                for (int i = 0; i < count; i++)
                {
                    plaintext[i] = buffer[offset + i];
                }
            }
            else
            {
                plaintext = buffer;
            }

            byte[] encrypted = _cipher.EncryptMessage(plaintext, count);
            _s.Write(encrypted, 0, encrypted.Length);
        }
Exemple #2
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (_mode == CryptoMode.Decrypt)
            {
                throw new NotImplementedException();
            }

            // workitem 7696
            if (count == 0)
            {
                return;
            }

            byte[] plaintext = null;
            if (offset != 0)
            {
                plaintext = new byte[count];
                for (int i = 0; i < count; i++)
                {
                    plaintext[i] = buffer[offset + i];
                }
            }
            else
            {
                plaintext = buffer;
            }

            byte[] encrypted = _cipher.EncryptMessage(plaintext, count);
            _s.Write(encrypted, 0, encrypted.Length);
        }
Exemple #3
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     if (_mode == CryptoMode.Decrypt)
     {
         throw new NotSupportedException("This stream does not Decrypt via Write()");
     }
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (count == 0)
     {
         return;
     }
     byte[] array = null;
     if (offset != 0)
     {
         array = new byte[count];
         for (int i = 0; i < count; i++)
         {
             array[i] = buffer[offset + i];
         }
     }
     else
     {
         array = buffer;
     }
     byte[] array2 = _cipher.EncryptMessage(array, count);
     _s.Write(array2, 0, array2.Length);
 }