What exactly is an SQL injection attack? What should a programmer do to prevent such an attack?

Jhonnatan R.

Answer:

An SQL injection attack consists of the insertion or "injection" of an SQL query by means of the input data from the client to the application. A successful SQL injection attack can read sensitive information from the database, modify the information (Insert / Update / Delete), execute management operations on the database. The main problem with these attacks is that if we let the user of the program freely enter characters without any control (using forms, for example) can get to take advantage of the quotes (simple and double with which we declare strings of text or strings).
In order to prevent and avoid these attacks, the programmer must avoid that special characters (such as quotes) could be introduced without first transforming them (for example, a double quotation mark: "it should be transformed into \" Character that closes or opens a text in the query, but according to the language can be implemented in different ways and some are automatic and more optimized to avoid the SQL injection.

Computer Science (General)

TutorMe

Question:

You are to consider bubble and selection sort. Both are O(n^2) however it may be possible to classify one algorithm as being more efficient than the other. You are to discuss which algorithm you feel is the most efficient and in what cases it will be more efficient. Provide any relevant test cases and code to support your belief.

Jhonnatan R.

Answer:

I feel that the selection algorithm is more efficient because the bubble sorting algorithm does more work to bring each element to its position.
This means that if we have a vector of 10000 elements then in a basic bubble algorithm 10000 comparisons are made to locate each element in its position.
The selection algorithm is also more efficient because of the number of exchanges it performs.
Ordering by selection will be more efficient in cases where we have few large records, so by analyzing the number of exchanges that the selection method makes, we see that it is of order O (n) versus the order O (n^2) of exchanges of the bubble method.
That is why in general we can say that the selection method does fewer iterations, exchanges, and comparisons than the bubble method as we can see in the following case proves:
Procedure Bubble (var Vector: tVector; N: tRange);
Var I, J: tRange;
Aux: tBase; {Auxiliary Element of the same type as the vector}
Begin
For I: = 1 to N - 1 Do {N-1 Cycle Iterations}
For J: = 1 to N-I Do {Bubble of the Highest Value}
If Vector [J]> Vector [J + 1] Then
Begin {Exchange}
Aux: = Vector [J];
Vector [J]: = Vector [J + 1];
Vector [J + 1]: = Aux;
End;
End;
Demonstration:
Given the following vector {40,21,4,9,10,35} we will sort it from lowest to highest.
First pass:
{21,40,04,09,10,35} <- The 21 is changed by 40.
{21,04,40,09,10,35} <- 40 is changed by 04.
{21,04,09,40,10,35} <- The 09 is changed by 40.
{21,04,09,10,40,35} <- 40 is changed by 10.
{21,04,09,10,35,40} <- The 35 is changed by 40.
Second pass:
{04,21,09,10,35,40} <- The 21 is changed by 04.
{04,09,21,10,35,40} <- The 09 is changed by the 21.
{04,09,10,21,35,40} <- The 21 is changed by 10.
Total iterations: 8
They are already ordered, but to verify it would have to finish this second test and make a third.
Now we test the selection sort..
Procedure Selecction (var Vector: tVector; N: tRange);
Var I, J: tRange;
Aux: tBase; {Auxiliary Element of the same type as the vector}
Begin
For I: = 1 to N - 1 Do {N-1 Cycle Iterations}
For J: = I + 1 to N Do
If Vector [I]> Vector [J] Then
Begin {Exchange}
Aux: = Vector [I];
Vector [I]: = Vector [J];
Vector [J]: = Aux;
End;
End;
Demonstration:
Given the following vector {40,21,4,9,10,35}, we will sort it from lowest to highest.
{04,21,40,09,10,35} <- The 04 is placed, the smallest, in the first position: the 04 is changed by the 40.
{04,09,40,21,10,35} <- The 09 is placed, in second position: the 09 is changed by the 21.
{04,09,10,21,40,35} <- The 10 is placed, in third position: the 10 is changed by the 40.
{04,09,10,21,40,35} <- The 21 is placed, in third position: already placed.
{04,09,10,21,35,40} <- The 35 is placed in third position: the 35 is changed by 40.
Total iterations: 5
They are already ordered, but to verify it would have to finish this second test and make a third.

C Sharp Programming

TutorMe

Question:

How to create a program in C # to add, subtract and multiply polynomials?

A lesson is virtual lesson space on our platform where you and a tutor can communicate.
You'll have the option to communicate using video/audio as well as text chat.
You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.

How do I begin a lesson?

If the tutor is currently online, you can click the "Start Session" button above.
If they are offline, you can always send them a message to schedule a lesson.

Who are TutorMe tutors?

Many of our tutors are current college students or recent graduates of top-tier universities
like MIT, Harvard and USC.
TutorMe has thousands of top-quality tutors available to work with you.