#include #include int dehex(char c) { if (c>='0' && c<='9') return (c-'0'); if (c>='A' && c<='F') return (c-'A'+10); if (c>='a' && c<='f') return (c-'a'+10); return (0); } void main(int argc, char *argv[]) { FILE *in=stdin, *out=stdout; char orikey[100],*key; int i,n; key=argv[1]; i=0; orikey[0]=0; /* read the argument, converting it from hexadecimal into an array of bytes */ while (*key!=0) { n=dehex(*key)<<4; key+=1; orikey[i]=n; orikey[i+1]=0; if (*key==0) break; n|=dehex(*key); key+=1; orikey[i]=n; i+=1; } key=orikey; /* read file, exclusive-oring each character with the next byte of the key */ while ((i=getc(in))>=0) { fputc(i^*key,out); *key; key+=1; if (*key==0) key=orikey; } }