[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux-team] Serveur web ...
>
> PB> P*tain: "xigulor"... où t'as trouvé un nick pareil ? :)
>
> Ex fan de X-OR ... une sorte de dérivé quoi ... et nan je m'envole pas par
> la fenetre en criant fulguraupoing, nan ! ;-)
>
voici un petit algo puisque tu aimes XOR :
#include <stdio.h>
#include <fcntl.h>
char buf[8192];
char bytes[256];
char * py;
/* do the xor, in place. Uses global ptr "py" to maintain "bytes" state
*/
xorb (buf, len)
char * buf;
int len;
{
register int x;
register char * pb;
pb = buf;
x = len;
while (x > 0) {
*pb = (*pb ^ *py);
pb++;
py++;
if (! *py)
py = bytes;
x--;
}
} /* xorb */
main (argc, argv)
int argc;
char ** argv;
{
register int x = 0;
register int y;
/* manually preload; xor-with-0xFF is all too common */
memset (bytes, 0, sizeof (bytes));
bytes[0] = 0xff;
/* if file named in any arg, reload from that */
#ifdef O_BINARY /* DOS shit... */
x = setmode (0, O_BINARY); /* make stdin raw */
if (x < 0) {
fprintf (stderr, "stdin binary setmode oops: %d\n", x);
exit (1);
}
x = setmode (1, O_BINARY); /* make stdout raw */
if (x < 0) {
fprintf (stderr, "stdout binary setmode oops: %d\n", x);
exit (1);
}
#endif /* O_BINARY */
if (argv[1])
#ifdef O_BINARY
x = open (argv[1], O_RDONLY | O_BINARY);
#else
x = open (argv[1], O_RDONLY);
#endif
if (x > 0) {
read (x, bytes, 250); /* nothin' fancy here */
close (x);
}
py = bytes;
x = 1;
while (x > 0) {
x = read (0, buf, sizeof (buf));
if (x <= 0)
break;
xorb (buf, x);
y = write (1, buf, x);
if (y <= 0)
exit (1);
}
exit (0);
}
----------------------------------------------------------
Alexandre J.D. Dulaunoy | Type bits/keyID (PGP Pub Key) |
adulau@unix.be.EU.org | pub 1024/4165497C |
_____________ (aka) AD993-RIPE/AD4384-DARPA ______________
"Anyone who attempts to generate random numbers by
deterministic means is, of course, living in a
state of sin." -- John von Neumann
----------------------------------------------------------
---------
This message was sent by Majordomo 1.94.3. Please report problems to
manu@rtfm.be. If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.