attenti che è molto veloce, non esagerate con la dimensione del file che potrebbe riempirvi il disco fisso!
- Code: Select all
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <conio.h>
int main()
{
FILE *fw;
float current, total, percent;
int j;
char c, d, temp;
char output_file[512];
char car[512] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
unsigned long i, l = 0, lenght, lenght_Byte;
printf("\n\n NorbiX's Password Generator \n\n");
printf("Generatore di password per cifrari di vigenere a chiave non ripetuta");
printf("\n\nInserire la lunghezza della password (MAX 4GB): ");
fflush(stdin);
scanf("%d", &lenght);
printf("\n1 - Byte");
printf("\n2 - kByte");
printf("\n3 - MByte");
printf("\n4 - GByte");
fflush(stdin);
d = getch();
printf("\n\n1 - Solo caratteri stampabili (a-z, A-Z, 0-9)");
printf("\n2 - Binario 0-255");
fflush(stdin);
c = getch();
printf("\n\nFile di output: ");
fflush(stdin);
gets(output_file);
printf("\nPremere un tasto per iniziare");
fflush(stdin);
getch();
fw = fopen(output_file, "w");
printf("\n\n");
if(d == '1') lenght_Byte = lenght;
if(d == '2') lenght_Byte = lenght*1024;
if(d == '3') lenght_Byte = lenght*1024*1024;
if(d == '4') lenght_Byte = lenght*1024*1024*1024;
if(c == '1')
{
j = strlen(car);
for(i = 0; i <= lenght_Byte; i++)
{
temp = car[(0 + rand() % j)];
putc(temp, fw);
if(i == l)
{
current = i;
total = lenght_Byte;
percent = (current/total) * 100;
printf("\r%.*f%%", 3, 2, percent);
l += (1024*100); // ogni 100kB mostra la percentuale
}
}
}
if(c == '2')
{
for(i = 0; i <= lenght_Byte; i++)
{
temp = 0 + rand() % 255;
putc(temp, fw);
if(i == l)
{
current = i;
total = lenght_Byte;
percent = (current/total) * 100;
printf("\r%*.*f%%", 3, 2, percent);
l += (1024*100); // ogni 100kB mostra la percentuale
}
}
}
fclose(fw);
printf("\r100.00%%");
printf("\n\nOperazione terminata");
fflush(stdin);
getch();
}
buona generazione!
