Xortext.c: Difference between revisions
From Hackepedia
Jump to navigationJump to search
No edit summary |
(No difference)
|
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 keyn");
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;
}