This project is read-only.

there's may be something wrong in the BlockCipher?

Aug 11, 2012 at 8:48 AM
        /// <summary>
        /// Encrypts the specified data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns>Encrypted data</returns>
        public override byte[] Encrypt(byte[] data)
        {
            var output = new byte[data.Length];

            if (data.Length % this._blockSize > 0)
            {
                if (this._padding == null)
                {
                    throw new ArgumentException("data");
                }
                else
                {
                    data = this._padding.Pad(this._blockSize, data);
                }
            }

            var writtenBytes = 0;

            for (int i = 0; i < data.Length / this._blockSize; i++)
            {
                if (this._mode == null)
                {
                    writtenBytes += this.EncryptBlock(data, i * this._blockSize, this._blockSize, output, i * this._blockSize);
                }
                else
                {
                    writtenBytes += this._mode.EncryptBlock(data, i * this._blockSize, this._blockSize, output, i * this._blockSize);
                }
            }

            if (writtenBytes < data.Length)
            {
                throw new InvalidOperationException("Encryption error.");
            }

            return output;
        }

this method will be wrong if I use CipherPadding(PKCS7Padding), the output just alawys small than it must be,and cause the" Invaid output buffer" Exception . I think this sentence
var output = new byte[data.Length];
must after than the if sentence that just like the Decrypt method.