Thread: Encryption/Decryption Program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    13

    Encryption/Decryption Program

    I am trying to build an encryption/decryption program for fun. I know it won't be strong, I know people would crack it in seconds but I don't care. This is just to get to grips with it. I have code that works with the XOR encryption method. It needs a bit of work but its operating and that was my goal. What I want to do is design a very simple algorithm to replace XOR in my code. I assume that I should write a function and replace
    Code:
    c^=*(key++);
    with my algorithm e.g.
    Code:
    c = algo(c, *key++);
    Can someone tell me how I might write a function to say increment every letter by 5, i.e. a = (a+5), b = (b+5), etc?

    I should know this but I'm blanking!

    Code so far:

    Code:
    #include <stdio.h>
    
    
    int main(int argc, char*argv[])
    {
    FILE *fp1, *fp2;
    char* key;
    int c;
    
    
    key = argv[1];
    
    
    	if(*key != '\0')
    	{
    	fp1 = fopen(argv[2],"rb");
    		if(fp1 != NULL)
    		{
    		fp2 = fopen(argv[3],"wb");
    		if (fp2 != NULL)
    		{
    			while((c=getc(fp1))!=EOF)
    			{
    				if(!*key)key = argv[1];
    				c ^=*(key++);
    	
    				putc(c, fp2);
    			}
    		fclose(fp2);
    		}
    	fclose(fp1);
    	}
    	}
    return 0;
    }
    Last edited by adohertyd; 12-21-2011 at 11:54 AM. Reason: inserted code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. encryption / decryption
    By ghatoz in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2010, 06:45 AM
  2. encryption / decryption program
    By epidemic in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2008, 06:40 AM
  3. Encryption/Decryption Help
    By coolage in forum C++ Programming
    Replies: 9
    Last Post: 04-25-2008, 01:53 AM
  4. Encryption and Decryption Program in C++ using a class
    By goron350 in forum C++ Programming
    Replies: 7
    Last Post: 06-05-2005, 09:29 PM
  5. Ask about Encryption and Decryption
    By ooosawaddee3 in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 12:55 AM

Tags for this Thread