Xortext.c: Difference between revisions
From Hackepedia
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
if (argc != 2) { | if (argc != 2) { | ||
fprintf(stderr, "must provide a | fprintf(stderr, "must provide a key\n"); | ||
exit(1); | exit(1); | ||
} | } | ||
Latest revision as of 05:28, 9 October 2005
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
u_long count = 0;
int keylen;
char *key;
u_char c;
if (argc != 2) {
fprintf(stderr, "must provide a key\n");
exit(1);
}
key = argv[1];
keylen = strlen(key);
while (read(STDIN_FILENO, &c, sizeof(c)) > 0) {
c ^= key[count % keylen];
write(STDOUT_FILENO, &c, 1);
count++;
}
return 0;
}