|
|
@ -40,11 +40,10 @@ int main(int argc, char** argv) { |
|
|
|
MPI_Init(NULL, NULL); |
|
|
|
|
|
|
|
int size,rank,strSize; |
|
|
|
short success = 1,sumSuccess = 1; |
|
|
|
TTiming czasomierzacz; |
|
|
|
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size); |
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
|
|
|
|
|
|
|
uint64_t i; //licznik, 64 bit-owy bo maxStrSize * offset = 10 * 6 = 60 bit; 4 bity w "zapasie" :-)
|
|
|
|
uint64_t maxKomb; //maxKomb to maksymalna ilosć kombinacji hasła = lexSize ^ strSize;
|
|
|
@ -53,16 +52,12 @@ int main(int argc, char** argv) { |
|
|
|
result = new char[41]; |
|
|
|
str = new char[maxStrSize]; |
|
|
|
|
|
|
|
if (!rank) czasomierzacz.Begin(); |
|
|
|
success = 0; |
|
|
|
czasomierzacz.Begin(); |
|
|
|
maxKomb = pow(lexSize,minStrSize-1); |
|
|
|
for(strSize = minStrSize;strSize<=maxStrSize;strSize++){ //petla generujaca jaka ma być długość hasła z którego bedzie generowany hash
|
|
|
|
maxKomb *= lexSize; |
|
|
|
i = rank; |
|
|
|
|
|
|
|
MPI_Allreduce(&success,&sumSuccess,1,MPI::SHORT,MPI::SUM,MPI_COMM_WORLD); |
|
|
|
if (sumSuccess > 0) break; |
|
|
|
|
|
|
|
while(i<maxKomb){//generowanie różnych haseł
|
|
|
|
for(int j=0;j<strSize;j++){ |
|
|
|
str[j] = lex[(i >> (offset*j)) & mask]; |
|
|
@ -70,26 +65,21 @@ int main(int argc, char** argv) { |
|
|
|
|
|
|
|
sha1((unsigned char*)str,strSize,result); //obliczanie hash z wygenerowanego wcześniej hasła
|
|
|
|
|
|
|
|
if(strcasecmp(argv[1],result) == 0){ //znalazłem odpowiedz 109
|
|
|
|
success = 1; |
|
|
|
|
|
|
|
if(strcasecmp(argv[1],result) == 0){ //znalazłem odpowiedz 109
|
|
|
|
cout<<endl<<" Złamałem hasha: "; |
|
|
|
for(int l=0;l<strSize;l++) cout<<str[l]; |
|
|
|
cout<<endl; |
|
|
|
} |
|
|
|
|
|
|
|
//niech więcej nie liczy po tej pętli while skoro znalazł
|
|
|
|
if (success > 0) |
|
|
|
break; |
|
|
|
cout<<" Czas = "<<czasomierzacz.End()<<" ms"<<endl<<endl; |
|
|
|
MPI_Abort(MPI_COMM_WORLD, MPI_SUCCESS); |
|
|
|
} |
|
|
|
i+=size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!rank) cout<<" Czas = "<<czasomierzacz.End()<<" ms"<<endl<<endl; |
|
|
|
if (!rank) cout << "Nie znaleziono!!!" << endl << endl; |
|
|
|
|
|
|
|
delete[] result; |
|
|
|
delete[] str; |
|
|
|
|
|
|
|
MPI_Finalize(); |
|
|
|
} |
|
|
|
|
|
|
|
MPI_Finalize(); |
|
|
|
} |