top of page

Comunidade TNB

Público·64 membros

How To Write A Password Cracking Program In Java WORK


DOWNLOAD - https://urlin.us/2tuhsm





How To Write A Password Cracking Program In Java


Password cracking is the process of finding out the original password from a hashed or encrypted one. Password cracking can be done for various purposes, such as testing the security of a system, recovering lost passwords, or hacking into someone else's account. In this article, we will show you how to write a simple password cracking program in Java using recursion and brute force.


What is recursion


Recursion is a technique in programming where a function calls itself repeatedly until a base case is reached. A base case is a condition that stops the recursion and returns a value. Recursion can be used to solve problems that involve breaking down a complex problem into smaller and simpler subproblems.


What is brute force


Brute force is a method of solving problems by trying all possible combinations of inputs until a solution is found. Brute force is usually not efficient or elegant, but it can be effective for some problems that have no better algorithm. Brute force can also be used to test the strength of a password by trying all possible passwords until the correct one is found.


How to write a password cracking program in Java


To write a password cracking program in Java, we need to do the following steps:


Create a class called Password that generates a random password of a given length using letters and digits.


Create a method called isPassword that compares a given string to the password and returns true if they are equal and false otherwise.


Create a recursive method called findPassword that takes a Password object and an integer length as parameters and returns the password if it is found or an empty string otherwise.


In the findPassword method, use a loop to iterate through all possible characters from 0 to Z and append them to a string.


Call the findPassword method recursively with the updated string and length until the length reaches zero or the password is found.


Print the result of the findPassword method.


Here is an example code for the password cracking program in Java:


```java


import java.util.Random;


public class PasswordCracker {


// A class that generates a random password of a given length


public static class Password


private String _password = "";


// Constructor that generates a password


public Password(int length)


Random generator = new Random();


for (int i = 0; i < length; ++i)


this._password = this._password + (char) (generator.nextInt(36) + 48);




// Method that compares a given string to the password


public boolean isPassword(String st)


return st.equals(this._password);




// A recursive method that finds the password by brute force


public static String findPassword(Password p, int length)


String pswd = "";


char char2Check = '0';


if (length == 0)


return "";


else


return findPassword(p, length, pswd, char2Check);




// An overloaded method that finds the password by brute force


public static String findPassword(Password p, int length, String pswd, char char2Check) {


if (pswd.length() < length)


pswd += char2Check;


pswd = findPassword(p, length, pswd, char2Check);


if (pswd.length() < length)


if (char2Check == 'Z')


return pswd;



if (char2Check < 'Z')


char2Check++;


pswd += char2Check;


return findPassword(p, length, pswd, char2Check);





if (pswd.length() == length) {


System.out.println(pswd);


if (p.isPassword(pswd))


return pswd;



if (char2Check < 'Z') {


pswd = pswd.substring(0, pswd.length() - 1);


char2Check++;





Informações

Bem-vindo à nossa comunidade! 😍 Você pode se conectar com o...
bottom of page