class BruteForce
{
    private String passwd;

    public BruteForce(String passwd)
    {
        this.passwd = passwd;
    }

    public void crack()
    {
        char testPass[] = new char[10];
        long startTime = System.currentTimeMillis();

        for(int i = 0; i < 94; i++)
        {
            testPass[0] = (char) (i+33);
            String temp = String.copyValueOf(testPass);

            if(passwd.compareTo(temp.trim()) == 0)
            {
                System.out.println("The password is: " + temp);
                System.out.println("Tid: " + (System.currentTimeMillis() - startTime));
                System.exit(0);
            }

            if(testPass[0] == 126)
            {
                i = -1;
                int j;
                for(j = 1; testPass[j] == 126; j++)             
                    testPass[j] = (char)33;
                if(testPass[j] == 0)
                    testPass[j] = 33;
                else
                    testPass[j]++;
            }
        }
    }
}

