Ja bih točno trebao znati što on radi jer se baš ne poznajem s tim.
Svaki koment posamičnog reda bi dobro došao, a što me najbolje zanima je algoritam ove enkripcije.
/* my l33t 3ncrypt10n pr0gr4m - K4v1n.
*/
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <process.h>
#include <io.h>
#include <sysstat.h>
unsigned char buffer[1024],state[256],x,y;
int infile,
outfile,
len;
char *pwd;
void init_crypt(char *keydata)
{ unsigned int i,keylen;
unsigned char index1,index2;
char newpass[100];
x=0;
y=0;
keylen=strlen(keydata);
printf("Key:%s, Length:%d",keydata,strlen(keydata));
strcpy(newpass,"H4ck3d4ndCr4ck3d");
strcat(newpass,keydata);
for(i=0;i<256;i++)
state[ i ]=(unsigned char)(i*73);
index1=0;
index2=0;
for(i=0;i<256;i++)
{ index2+=keydata[index1]+state[ i ];
x=state[index2];
state[index2]=state[ i ];
state[ i ]=x;
index1=(index1+1)%keylen;
}
x=0;
}
void process_string(unsigned char *inoutstring,unsigned int length)
{ unsigned char a,b;
while(length--)
{ a=state[++x];
y+=a;
b=state[y];
state[y]=a;
a+=b;
state[x]=b;
(*inoutstring++)^=state[a];
}
}
void main(int argc,char *argv[])
{ if(argc!=4)
{ printf("Usage : encrypt <infile> <outfile> <password>n");
exit(1);
}
if ((infile=open(argv[1],O_BINARY))==-1)
{ printf("Can't Open : %sn",argv[1]);
exit(1);
}
if((outfile=open(argv[2],O_WRONLY|O_CREAT|O_BINARY,S_IWRITE))==-1)
{ printf("Can't Open : %sn",argv[2]);
exit(1);
}
pwd=argv[3];
init_crypt(pwd);
for(;;)
{ if((len=read(infile,buffer,1024))==0)break;
process_string(buffer,len);
write(outfile,buffer,len);
}
close(outfile);
close(infile);
}
poz Boris
"Multitasking - ability to f##k up several things at once."
"It works better if you plug it in."
"As a rule, software systems do not work well until they have been used, and have failed repeatedly, in real applications."
"The one who is digging the hole for the other to fall in is allready in it."