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);
}

Recommended Answers

All 3 Replies

Be more specific. Which arrays? Where do they get values and where do you want to print them?

Well. new question.

The compiler keeps flagging warnings on arguments 2 and 6 of the call to RC4 on line 40. It keeps telling me that I am using incompatible pointer types.

What does that mean?

#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, int *netpos);
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;
  int *netpos;
  // used for cycling algorithm
  CurrentChangingValue, netpos, 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++)
  {
      *netpos = 0;
      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, &netpos);
         //statisticpw[CurrentChangingValue][temp + increment] = 
      }
  }
 // Statistic_Analysis(statisticpw);
 
 system("PAUSE");
  return 0;
}

void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue, int *netpos)
{
	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;
                      
                      *netpos = *netpos + 1;
                      positivecorrelations = positivecorrelations + 1;
                     // Stats[CurrentChangingValue][j][positivecorrelations] = Stats[CurrentChangingValue][j][positivecorrelations];
                      printf ("Current: %d | Increment: %d | Smeared: %d | +: %d | net+: %d \n", CurrentChangingValue, (increment + temp), j, positivecorrelations, netpos);  
             }
         }
    }
}

                      
/*			
       if (k%100 == 1) //temp
			{

			printf ("test positivecorrelations = %d \n", positivecorrelations); ///temp
			printf ("test statisticpw = %d \n ", statisticpw[k]); ///temp
            }                    
		   printf("*");
		else
		   printf("-");
		}
		return positivecorrelations;
     }
}
void Statistic_Analysis(int *statisticpw)
{
	int iterate, z, group, b;
    iterate, z, group, b = 0;
	int groupcorrelations[9];
    for (z = 0; z < 360 ; z++)
	{
		if (b != 40)
		{
		       groupcorrelations[group] = groupcorrelations[group] + statisticpw[z];
        }
		else
		{
			printf ("positive correlations = %d\n", groupcorrelations[group]);
			b = 0;
			group = group + 1;
		}
	}
 }
 
 */
 /*
   if (CurrentChangingValue == 9 && increment == 20)
    {
                               printf ("Smear: ");
                      for (i = 0; i < 11; i++)
                      {printf("%d = %d  ", i, StatsSmear[i]);}
                      
                      printf ("--------------------------------------- \n ChangingValue");
                      for (i = 0; i < 10; i++)
                      {printf("%d = %d  ", i, StatsValue[i]);}
                      
                       printf ("--------------------------------------- \n Increment");
                       for (i = 0; i < 40; i++)
                       {printf("%d = %d  ", i, StatsIncrement[i]);}
                       }
                       */
char GetRand()
{
  static char Init = 0;
  char rc;
  if (Init == 0)
  {
    srand(time(NULL));
    Init = 1;
  }
  rc = (rand() % (MAX - MIN + 1) + MIN);
  return (rc);
}

>What does that mean?
Easy, you are passing the wrong parameters.

Q: What's argument two of RC4?
A:testpw
Q: What's char testpw[9][40]?
A: for you to think about it.
Q: What does the prototype of void RC4() says it has to be?
A:

void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue, int *netpos);

Selected in red.
Q:Is testpw[9][40] same thing than char *testpw?
A: for you to think about it.

For warning concerning argument 6 follow the same procedure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.