Hi guys, plz help. I write simple cryptor:
Code:
#include <stdio.h>
int main(int argc, char* argv[])
{
FILE *fp;
int z,i=0;
int rbyte;
printf("One-time pad cryptor.\n");
if (argc!=3) {printf("Usage: %s file cryptkey\n",argv[0]); return 0;}
if (fp=fopen(argv[1],"rw")==0) { printf("Error opening file %s\n",argv[1]); return 0;}
z=strlen(argv[2]);
printf("%d\n",z);
while ((rbyte=fgetc(fp)))
{
if (i<=z) i=0;
rbyte=rbyte^argv[2][i];
fputc(rbyte,fp);
i++;
}
fclose(fp);
return 0;
}
I got segmentation fault. What's the problem?