Cryptology 427
return (((enum_hashbyte(c)%4)4096)+(enum_hashbyte(a)64)+enum_hashbyte(b));
}
/ Barf a message and exit. /
void barf(char message, char extra) {
printf(message, extra);
exit(1);
}
/ Generate a 4–char.ppm file with all possible 4-char passwords (salted w/ je). /
int main() {
char plain[5];
char code, data;
int i, j, k, l;
unsigned int charval, val;
FILE *handle;
if (!(handle = fopen("4char.ppm", "w")))
barf("Error: Couldn't open file '4char.ppm' for writing.\n", NULL);
data = (char *) malloc(SIZE);
if (!(data))
barf("Error: Couldn't allocate memory.\n", NULL);
for(i=32; i<127; i++) {
for(j=32; j<127; j++) {
printf("Adding %c%c** to 4char.ppm..\n", i, j);
for(k=32; k<127; k++) {
for(l=32; l<127; l++) {
plain[0] = (char)i; // Build every
plain[1] = (char)j; // possible 4-byte
plain[2] = (char)k; // password.
plain[3] = (char)l;
plain[4] = '\0';
code = crypt((const char )plain, (const char )"je"); // Hash it.
/ Lossfully store statistical info about the pairings. /
val = enum_hashtriplet(code[2], code[3], code[4]); // Store info about bytes 2-4.
charval = (i-32)95 + (j-32); // First 2 plaintext bytes
data[(valWIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT 4);
charval = (k-32)95 + (l-32); // Last 2 plaintext bytes
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val = HEIGHT + enum_hashtriplet(code[4], code[5], code[6]); // bytes 4-6
charval = (i-32)95 + (j-32); // First 2 plaintext bytes
data[(valWIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT 4);
charval = (k-32)95 + (l-32); // Last 2 plaintext bytes
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val = (2 HEIGHT) + enum_hashtriplet(code[6], code[7], code[8]); // bytes 6-8
charval = (i-32)95 + (j-32); // First 2 plaintext bytes
data[(valWIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT 4);