If you look at the end, i try to store some values in a few arrays.
When i try to print these out, I receive complete junk.
any thoughts?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define MAX 122
#define MIN 48
char GetRand();
void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue);
void Statistic_Analysis(int *statisticpw);
int main()
{
unsigned char S1[256];
unsigned char S2[256];
char testpw[9][40];
char realpw[9];
char statisticpw[9][40];
char increment;
char CurrentChangingValue, r;
char temp;
// used for cycling algorithm
CurrentChangingValue, r = 0;
temp = 20;
for (r = 0; r <= 8; r++)
{
realpw[r] = GetRand(); //generates a psuedo-random integers that serve as values for each password character
}
for (CurrentChangingValue = 0; CurrentChangingValue <= 9; CurrentChangingValue++)
{
for (increment = -20; increment <= 20; increment++)
{
if (increment == 0){ increment = increment + 1; }
testpw[CurrentChangingValue][temp + increment] = (realpw[CurrentChangingValue] + increment);
RC4(realpw, testpw, increment, temp, CurrentChangingValue);
//statisticpw[CurrentChangingValue][temp + increment] =
}
}
// Statistic_Analysis(statisticpw);
system("PAUSE");
return 0;
}
void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue)
{
int positivecorrelations;
unsigned char S1[256];
unsigned char S2[256];
int StatsSmear[11];
int StatsValue[10];
int StatsIncrement[40];
int i, j, j1, j2, t, N1, N2, w, l;
for (i = 0; i<= 11; i++)
{ StatsSmear[i] = 0; }
for (i = 0; i<= 10; i++)
{ StatsValue[i]; }
i = positivecorrelations = 0;
N1 = 11; // testpw
N2 = 11; // realpw
for(i = 0; i < 256; i++)
{
S1[i] = S2[i] = i;
}
j1 = j2 = i = 0;
for(i = 0; i < 256; i++)
{
j1 = (j1 + S1[i] + realpw[i % N1]) & 0xFF;
j2 = (j2 + S2[i] + testpw[i % N2]) & 0xFF;
t = S1[i];
S1[i] = S1[j1];
S1[j1] = t;
t = S2[i];
S2[i] = S2[j2];
S2[j2] = t;
}
// so that the correlations 'from pw are not added to those of the next and so on.
i = positivecorrelations = 0;
j = -5;
for(i = 0; i < 256; i++)
{
for (j = -5; j <= 5; j++) //smear
{
if(S1[i] == S2[i + j])
{
StatsSmear[j] = StatsSmear[j] + 1;
StatsValue[CurrentChangingValue] = StatsValue[CurrentChangingValue] + 1;
StatsIncrement[increment] = StatsIncrement[increment] + 1;
//positivecorrelations = positivecorrelations + 1;
//Stats[CurrentChangingValue][j][positivecorrelations] = Stats[CurrentChangingValue][j][positivecorrelations];
//printf ("CurrentChangingValue: %d | number analyzed: %d | Amount Smeared: %d | positivecorrelations: %d \n", CurrentChangingValue, (increment + temp), j, positivecorrelations);
}
}
}
}
char GetRand()
{
static char Init = 0;
char rc;
if (Init == 0)
{
srand(time(NULL));
Init = 1;
}
rc = (rand() % (MAX - MIN + 1) + MIN);
return (rc);
}