Posted in Technology

Brute Force

Introduction

“Data is the new oil” this is the new mantra which is ruling the global economy. We are living in the digital world and every business revolves around data which translates into profits and help the industries to stay ahead of their competition. With the rapid digitization, exponential increase in the app based business model, cyber-crimes is a constant threat. One such common activity which hackers perform is the Brute force.

Brute Force is a trial and error approach where attackers use programs to try out various combinations to break into any websites or systems. They use automated software to repetitively generate the User id and passwords combinations until it eventually generates the right combination.

Brute-Force Search

Brute force search is the most common search algorithm as it does not require any domain knowledge, all that is required is a state description, legal operators, initial state and the description of a goal state. It does not improve the performance and completely relies on the computing power to try out possible combinations.

The brute force algorithm searches all the positions in the text between 0 and n-m whether the occurrence of the pattern starts there or not. After each attempt, it shifts the pattern to the right by exactly 1 position. The time complexity of this algorithm is O(m*n). so if we are searching for n characters in a string of m characters then it will take n*m tries.

Let’s see a classic example of a traveling salesman to understand the algorithm in an easy manner.

Suppose a salesman needs to travel 10 different cities in a country and he wants to determine the shortest possible routes out of all the possible combinations. Here brute force algorithm simply calculates the distance between all the cities and select the shortest one.