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

#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
using namespace std;
/*
const int lexSize = 64; //rozmiar musi być potęgą liczby 2!!!!
char lex[64] = {'a','b','c','d','e','f','g','h',
'i','j','k','l','m','n','o','p',
'r','s','t','u','v','w','x','y',
'z','A','B','C','D','E','F','G',
'H','I','J','K','L','M','N','O',
'P','R','S','T','U','V','W','X',
'Y','Z','0','1','2','3','4','5',
'6','7','8','9','_',' ','-','!',};
*/
const int lexSize = 4;
char lex[4] = {'a','b','c','d'};
int main(){
unsigned int strSize =2,offset;
uint64_t i,temp,maxKomb,mask;
offset = 2; // [6] ile bitów potrzeba do zapisania liczby lexSize-1 np lexSize=4 to wtedy offset = 2;
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
maxKomb = pow(lexSize,strSize); //maksymalna ilosć komvinacji hasła = lexSize ^ strSize;
i = 0;
char *str;
str = new char[strSize];
while(i<maxKomb){
temp = i;
for(int j=0;j<strSize;j++){
temp = temp >> (offset*j);
str[j] = lex[temp & mask];
}
printf("%s\n",str);
i++;
}
return 0;
}