37 lines
685 B
C
37 lines
685 B
C
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
unsigned char next(
|
|
unsigned char lfsr, // le registre
|
|
unsigned char retroaction_f // les bits selectionnés par la
|
|
) // fonction de retroaction
|
|
{
|
|
// TODO
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int fd_in,fd_out;
|
|
unsigned char w,buf,f;
|
|
|
|
|
|
assert(argc >= 4);
|
|
fd_in = open(argv[1],O_RDONLY);
|
|
fd_out = open(argv[2],O_WRONLY|O_TRUNC|O_CREAT,0600);
|
|
w = (unsigned char)strtol(argv[3],NULL,0);
|
|
f = ; // TODO
|
|
|
|
while(1){
|
|
ssize_t nb = read(fd_in,&buf,1);
|
|
if (nb <=0)
|
|
break;
|
|
buf ^= w;
|
|
write(fd_out,&buf,1);
|
|
w=next(w,f);
|
|
}
|
|
return 0;
|
|
}
|