public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            byte[] tempBuffer     = new byte[64];
            int    encryptedBytes = 0;

            while (inputCount > 0)
            {
                Salsa20Transformation.SalsaBlock(tempBuffer, _state, _rounds);
                Salsa20Transformation.IncrementSalsaState(_state);

                int blockSize = Math.Min(InputBlockSize, inputCount);
                for (int i = 0; i < blockSize; i++)
                {
                    outputBuffer[outputOffset + i] = (byte)(inputBuffer[inputOffset + i] ^ tempBuffer[i]);
                }

                encryptedBytes += blockSize;

                inputCount   -= InputBlockSize;
                outputOffset += InputBlockSize;
                inputOffset  += InputBlockSize;
            }

            return(encryptedBytes);
        }
        public Salsa20Encryptor(byte[] key, byte[] iv, uint rounds)
        {
            if (key.Length != 16 && key.Length != 32)
            {
                throw new ArgumentException($"Key length not supported: {key.Length}");
            }

            if (iv.Length < 8)
            {
                throw new ArgumentException($"Invalid initialization vector size: {iv.Length}");
            }

            _rounds = rounds;
            _state  = Salsa20Transformation.CreateInitialState(key, iv);
        }