Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9056545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:14:07+00:00 2026-06-16T14:14:07+00:00

I have a brute force algorithm, but never fully understood it. I have a

  • 0

I have a brute force algorithm, but never fully understood it. I have a vague grasp of some of the things that go on, but every time I try to follow what happens exactly, I get lost (for example, the index variable is a little confusing). Any offers on how to make the algorithm more efficient are also welcome.

Note – I already have the algorithm, and it compiles and works. Please don’t accuse me of trying to use this for malicious intent, because I haven’t used it for that purpose, and I never plan to. I just want to know how it works.

public class BruteForceTest
{
    public String username = new String();
    public static String password = "ZZZZZ";
    public static char[] charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
    private static char[] currentGuess = new char[1];

public static void bruteForce()
    {
        String attempt = new String();
        Date start = new Date();
        while (true)
        {
            if (attempt.equals(password))
            {
                Date end = new Date();
                System.out.println("Password: " + attempt + "\nTotal time to crack: " + ((end.getTime() - start.getTime()) / 1000) + " seconds." + "\n");
                break;
            }
            attempt = in.toString();
            // System.out.println("Tried: " + attempt);
            in.increment();
        }
    }

    public BruteForceTest()
    {
        Arrays.fill(currentGuess, charset[0]);
    }

    public void increment()
    {
        int index = currentGuess.length - 1;
        while (index >= 0)
        {
            if (currentGuess[index] == charset[charset.length - 1])
            {
                if (index == 0)
                {
                    currentGuess = new char[currentGuess.length + 1];
                    Arrays.fill(currentGuess, charset[0]);
                    break;
                }
                else
                {
                    currentGuess[index] = charset[0];
                    index--;
                }
            }
            else
            {
                currentGuess[index] = charset[Arrays.binarySearch(charset, currentGuess[index]) + 1];
                break;
            }
        }
    }

    public String toString()
    {
        return String.valueOf(currentGuess);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:14:09+00:00Added an answer on June 16, 2026 at 2:14 pm

    Brute forcing is a heuristic technique that means, essentially, you’re going to try to analyze every possible scenario by taking advantage of how much faster a computer is than a human brain. For example, you’re not trying to deductively figure out the password or the next best move in a Chess game; you just test every possible situation and use the right one (or the best one according to some metric, depending on what the brute force algorithm is meant to accomplish).

    Your code simply goes through all the possible values that could be held for a password and checks to see whether it has found it or not. If it doesn’t, it moves on to the next possible combination until it does.

    It’s also a demonstration of a worst-case scenario, since the password, being defined as ZZZZZ, will be the last thing the algorithm attempts as a solution (assuming the maximum password length is defined as five characters.)

    Also, as far as you being worried that people think you’re using this algorithm for malicious purposes, I wouldn’t be too concerned. Hardly any computer systems would actually be vulnerable to this kind of attack, and you would be locked out long before you ever actually happened upon a password.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple (brute-force) recursive solver algorithm that takes lots of time for
I have this grand idea to basically employ some brute force attack to test/verify
Some background: I'm writing a more or less brute force search algorithm for solving
Any cryptography text mentions that in brute force attack on Symmetric Algorithm there is
have written this little class, which generates a UUID every time an object of
I tried solving this problem in SPOJ using Booth Algorithm in O(n) time, but
On my school assignment i have to find a string with a brute force
Not sure how to word this algorithm question, actually. I have toggle buttons in
I tried thinking of an algorithm, but couldn't do it. Here is the problem:
I have thousands of lines of 1 to 100 numbers, every line define a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.