/    Sign up×
Community /Pin to ProfileBookmark

parallel programming code is very slow

I’m studying about parallel programming and testing this brute force code, to crack a password with 7 positions without and with parallelism, but when applying parallel programming, the code is running slower than before. Does anyone know why? How can I use parallel programming in this code to make it faster? thanks.

“`
public class Worker extends Thread{

private static final int[] valuesCaracter = {48, 48, 48, 48, 48, 48, 48};
private static final int arraySize = valuesCaracter.length;
private static char[] symbols = new char[arraySize];
private static String password = null;

@Override
public void run() {
generatePasswordCaracters();
}

public static int ajustaValor(int valueASCII) {
return switch (valueASCII) {
case 58 -> 65;
case 91 -> 97;
default -> valueASCII;
};
}

public static String generatePasswordCaracters() {

for (int i = 0; i < arraySize; i++) {
while (valuesCaracter[i] <= 122) {

for (int j = 0; j < symbols.length; j++) {
symbols[j] = (char) valuesCaracter[j];

}

password = new String(symbols);

System.out.println(password);

valuesCaracter[6]++;

for(int k = arraySize – 1; k >= 1; k–) {
if (valuesCaracter[k] > 122) {
valuesCaracter[k – 1]++;
valuesCaracter[k] = 48;
} else {
valuesCaracter[k] = ajustaValor(valuesCaracter[k]);
}
}
}
}
return password;
}
}

import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.model.FileHeader;
import java.io.File;
import java.util.List;

public class App {

public static void main(String[] args) {

Worker[] Workers =
{new Worker(),
new Worker(),
new Worker(),
new Worker(),
new Worker(),
new Worker()};

for (Worker workerStart : Workers) {
workerStart.start();
}

try {
for (Worker workerJoin : Workers) {
workerJoin.join();
}
}catch (InterruptedException e) {
System.out.println(e.getMessage());
}

try {
ZipFile zipFile = new ZipFile(new File(“C:\vsCodeProjects-Java\BruteForce\src\file.zip”));
if (zipFile.isEncrypted()) {

zipFile.setPassword(Worker.generatePasswordCaracters().toCharArray());
}
List<FileHeader> fileHeaderList = zipFile.getFileHeaders();

for (FileHeader o : fileHeaderList) {

zipFile.extractFile(o, “C:\vsCodeProjects-Java\BruteForce\src”);
System.out.println(“This is the password”);
}

} catch (Exception e) {
System.out.println(“Wrong password”);
}
}
}
“`

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumMay 10.2022 — Please use code tags when posting code: `your code here` or triple backticks. I edited your posting accordingly.
Copy linkTweet thisAlerts:
@aquatecMay 11.2022 — Then try to use shopify for this. If you don't know how then you can take [url=https://aquatecinnovative.com/shopify-development-services/]Shopify Development Services[/url]

from freelancers but I suggest you to take it from Aquatec Innovative Pvt. Ltd.
×

Success!

Help @VictorJohnsonandroni spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...