#include #include #include int main(void) { char data[100]; int key; int length; int i; /* Start Encrypt */ printf("Enter 2 digits key: "); scanf("%d", &key); flushall(); printf("\nEnter data to encrypt: "); scanf("%[^\n]", &data); length = strlen(data); for(i=0; i |
I've been studying up on XOR encryption, planning on using it in another cipher program I have as a way for users to generate their own special keys. I've got the structure of the program written pretty well, but I've started to notice some odd things. Code: Usage programname inputfile[-] outputfile[-] key '-' for stdin or stdout #include #include ... |
Hey guys, I'm trying to develop a Xor ecnryption function but I'm having some problems... Here's what I've so far: Code: #include int main(int argc, char *argv[]) { char string[] = "This is a test!!!"; char key[] = "123"; XorEncrypt (&string, &key); printf("%s", string); getch(); return 0; } int XorEncrypt (char *string, char *key) { int cnt = 0, i, ... |
long time; /* know C? */ Unprecedented performance: Nothing ever ran this slow before. Any sufficiently advanced bug is indistinguishable from a feature. Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31. The best way to accelerate an IBM is at 9.8 m/s/s. recursion (re - cur' - zhun) n. 1. (see recursion) |
I need some help with a XOR program I'm trying to write. I need to know if I'm on the right track here, and how I could decrypt it all. Reverse the process, so to speak. Please have a look at this code, but ignore all the unnecessary printf's, I'm just trying to follow the code through step by step. Are ... |
well I have another problem. I make the SLIGHTEST change to Dave_Sinkula's above code, and all of the sudden it stops working. it is now outputting strings of lengths nothing close to the length of the input string, in funny characters ontop of that (again, what looks like what is caused by an overrun, things like smiley face characters and such). ... |
The way to see if you are close is to try it out. I used this short program to test out your encoder: Code: #include #include void decrypt (unsigned char buf[37]) { unsigned int nBitNr; unsigned int nIndex = 4; unsigned int nKey = (unsigned int)buf[3] << 24; nKey |= (unsigned int)buf[2] << 16; nKey |= (unsigned int)buf[1] << ... |
|
How does that not do what I want? If j is larger than the size of the array I want to set j back to zero. I guess I should just do j = 0 then. That would probably be faster. Anways before I had the <= the last byte of the string was always messed up as well, so I ... |
>> i know long int is 64 bits The ANSI standard for C (and as far as I know, C++ as well) only says that "the only restriction on the size of long is that it cannot be shorter than the int type". Currently on a 32-bit gcc compiler, both int and long are 32 bits in size. On the 64-bit ... |
//XOR Encryption #include #include //XOR Encryption key char XORkey [] = "simples"; void XOR_encrypt(char* input_file, char* output_file, char* key) { //Open input and output files FILE* input = fopen(input_file, "r"); FILE* output = fopen(output_file, "w"); //Check input file if (input == NULL) { printf("Input file cannot be read.\n"); return; } //Check output file if (output == NULL) { printf("Output ... |
#include int main(int argc, char *const *argv) { if ( argc == 4 ) { FILE *input = fopen(argv[1], "rb"); FILE *output = fopen(argv[2], "wb"); if ( input != NULL && output != NULL ) { unsigned char buffer[BUFSIZ]; size_t count, i, j = 0; do { count = fread(buffer, sizeof *buffer, sizeof buffer, input); for ( i = 0; ... |