You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

7 years ago
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <stdint.h>
  7. #include <math.h>
  8. using namespace std;
  9. /*
  10. const int lexSize = 64; //rozmiar musi być potęgą liczby 2!!!!
  11. char lex[64] = {'a','b','c','d','e','f','g','h',
  12. 'i','j','k','l','m','n','o','p',
  13. 'r','s','t','u','v','w','x','y',
  14. 'z','A','B','C','D','E','F','G',
  15. 'H','I','J','K','L','M','N','O',
  16. 'P','R','S','T','U','V','W','X',
  17. 'Y','Z','0','1','2','3','4','5',
  18. '6','7','8','9','_',' ','-','!',};
  19. */
  20. const int lexSize = 4;
  21. char lex[4] = {'a','b','c','d'};
  22. int main(){
  23. unsigned int strSize =2,offset;
  24. uint64_t i,temp,maxKomb,mask;
  25. offset = 2; // [6] ile bitów potrzeba do zapisania liczby lexSize-1 np lexSize=4 to wtedy offset = 2;
  26. mask = 0x3; // [0x3f] np dla maxKomb zapisanego na 64bitach to jest 58 zer i 6 (czyli offset) jedynek: 0000000 0000000 0000000 0000000 0000000 0000000 0000000 00111111
  27. maxKomb = pow(lexSize,strSize); //maksymalna ilosć komvinacji hasła = lexSize ^ strSize;
  28. i = 0;
  29. char *str;
  30. str = new char[strSize];
  31. while(i<maxKomb){
  32. temp = i;
  33. for(int j=0;j<strSize;j++){
  34. temp = temp >> (offset*j);
  35. str[j] = lex[temp & mask];
  36. }
  37. printf("%s\n",str);
  38. i++;
  39. }
  40. return 0;
  41. }