有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

用于计算暴力破解密码时间的java程序返回0或4009813075秒

我决定制作一个程序,估计用GTX 1070暴力破解SHA256密码所需的时间。大概,我已经输入了所有需要的内容,但它只会返回0或4009813075秒(128年10个月29天20小时57分55秒)

我认为问题可能在第66行,因为我计算了该长度和密码类型的符号组合总数,然后将其转换为(可能有些数字对于?)太大了。无论如何,也许我不应该在我的第一次作业中使用大指数,但我希望我能让其他人看看这个,告诉我他们的想法

import java.util.Scanner;

public class Hashtime {

public static void main(String[] args) {
    System.out.println("The purpose of my program will be to estamate the required time to crack a SHA256 password using a GTX 1070,\nmore specifically based on the real world performance of the ASUS STRIX GTX 1070 in my desktop.\n");
    // TODO Auto-generated method stub
long GTX_1070_SHA256_HASHRATE = 2300200000L; //The hash rate constant in hash per second
int pass_len; //length of the password as given from the user
int pass_type; //Represents what the password consists of
int pass_power; //Found from pass_type, it is the number of symbols that could be at each location in the password
long pass_combo; //found as the product of pass_len and pass_power, it is the total number of combos that your password could be
long time_sec; //total number of seconds required to brute force all combos

// The following variables combined together equal time_sec. Example, 10 days 23 hours 10 minutes and 57 seconds
long time_years_t;
int time_months_t;
int time_days_t;
int time_hours_t;
int time_minnutes_t;
int time_seconds_t;
int mod_time; //remaining time after division to find values
int mod_time_b; //When I need to keep the old mod and calculate a new mod
Scanner scn = new Scanner(System.in); //initiates scanner

System.out.println("What is the length of your password?");
pass_len = scn.nextInt(); //Determines the length of the password by promoting the user
System.out.println("");

System.out.println("What is contained in your password? (Enter the matching number)\n1) Lower Case Only\n2) Upper Case Only\n3) Lower and Upper Case\n4) Lower Case and numbers\n5) Upper Case and numbers\n6) Lower Case, Upper Case, and Numbers\n7) Just Numbers");
pass_type = scn.nextInt(); //Determines how the password is constructed to determine the character set
System.out.println("");

//*********************Find pass_power***********************************//
if(pass_type == 1) {
    pass_power = 26;
}
else if(pass_type == 2) {
    pass_power = 26;
}
else if(pass_type == 3) {
    pass_power = 26+26;
}
else if(pass_type == 4) {
    pass_power = 26+10;
}
else if(pass_type == 5) {
    pass_power = 26+10;
}
else if(pass_type == 6) {
    pass_power = 26+26+10;
}
else if(pass_type == 7) {
    pass_power = 10;
}
else {
System.out.println("Sorry, you entered an invalid number");
    pass_power = -1;
}
//**********************end find pass_power******************************//

if(pass_power == -1) {

}
else {
    pass_combo = (long) Math.pow(pass_len, pass_power); //Finds the total number of possible combinations of characters that your password could be
    time_sec = pass_combo / GTX_1070_SHA256_HASHRATE;

    //********Years*******//
    mod_time = (int) (time_sec % 31104000);
    time_years_t = (time_sec - mod_time)/31104000;
    //*******Months*******//
    mod_time_b = mod_time % 2592000;
    time_months_t = (mod_time - mod_time_b) / 2592000;
    //********Days********//
    mod_time = mod_time_b % 86400; //finding the remainder of time_sec after dividing by the number of seconds in a day
    time_days_t = (mod_time_b - mod_time) / 86400; //finds the number of days, less the remainder
    //********hours*******//
    mod_time_b = mod_time % 3600; ////finding the remainder of mod_time (days remainder) after dividing by the number of seconds in an hour
    time_hours_t = (mod_time - mod_time_b) / 3600;//finds the number of hours less the remainder
    //*******Minutes******//
    mod_time = mod_time_b % 60;//finding the remainder of time_sec after dividing by the number of seconds in a minute
    time_minnutes_t = (mod_time_b - mod_time) / 60;//finds the number of minnutes less the remainder
    //*******Seconds******//
    time_seconds_t = mod_time;


    System.out.println("Your password will take no longer than "+time_years_t+" years, "+time_months_t+" months, "+time_days_t+" days, "+time_hours_t+" hours, "+time_minnutes_t+" minutes, "+time_seconds_t+" seconds to crack with a GTX 1070\n");
}
}
}

共 (0) 个答案