Thread: Encryption Contest

  1. #31
    ---
    Join Date
    May 2004
    Posts
    1,379
    Quote Originally Posted by ILoveVectors
    i could be wrong but that doesnt look
    like original, looks like XOR,
    not to mention, the key is right there.

    good try though, we need more people, keep
    them comming.
    heh I know, it was kind of a joke. I really know nothing about encryption.

  2. #32
    Banned
    Join Date
    Jun 2005
    Posts
    594
    maybe you could use this oppurtunity to come up with something

  3. #33
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    Quote Originally Posted by ILoveVectors
    Code:
    			for(int j = 0; j != 3; j++,i++)//applys 3 character of the key to character read in
    			{
    				changed1 = (letter-mykey[i]);//subtract mykey[i] thru mykey[i+3] from original letter
    			}
    This code (and the equivalent decrypting bit) seem a bit suspect. Surely it only actually applies the third of the 3 key characters you are meaning to apply. Shouldn't it be more like:-

    Code:
    			changed1 = letter;
    			for(int j = 0; j != 3; j++,i++)//applys 3 character of the key to character read in
    			{
    				changed1 -= mykey[i];//subtract mykey[i] thru mykey[i+3] from original letter
    			}
    I could be completely wrong...

    Pete

  4. #34
    Banned
    Join Date
    Jun 2005
    Posts
    594
    that is a good catch i spent more time putting
    in stuff to protect the user instead of actually
    checking what i did, i suppose since it encrypted
    and decrypted correctly i didnt put to much thought into it.

    its ok though i added it to my fix list, i was gonna make some changes so i can encrypted the file to the same file,
    and possibly use several keys. i still got
    some time before the contest is over anyways.

  5. #35
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    Fkulvwldqv 0 Nlwwbc 4 !!!!

  6. #36
    Banned
    Join Date
    Jun 2005
    Posts
    594
    OK my final entry, i never got around to doing everything
    i wanted to cause i was busy, but oh well

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <vector>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {	
    	string mykey;
    	string infile;
    	string outfile;
    
    	int choice;
    	cout << "1. Encrypt" << endl;
    	cout << "2. Decrypt" << endl;
    	cout << "Your Choice : ";
    	cin >> choice;
    	cin.ignore();
    	if(!cin)//Checks for bad input
    	{
    		cout << "I tried to figure out what you wanted" << endl;
    		cout << "but your want eludes me." << endl;
    		cout << "Program has been terminated!" << endl;
    		return 1;
    	}
    	if(choice == 1)//Load encrypt Section
    	{
    		cout << "Enter your key (Must be at least 8 characters): ";
    		getline(cin, mykey, '\n');
    		cout << "Location of file to encrypt, Ex \"c:/myfile.txt\" : ";
    		getline(cin, infile, '\n');
    		cout << "Location to save encrypted file, Ex \"c:/myoutfile.txt\" : ";
    		getline(cin, outfile, '\n');
    		int keysize = mykey.size();
    
    		if(keysize <= 7)
    		{
    			mykey.clear();
    			cout << endl << endl;
    			cout << "Your key was to short, here is a chance to fix that." << endl;
    			cout << "Enter a Key : ";
    			getline(cin, mykey, '\n');
    			keysize = mykey.size();
    			if(keysize <= 7)
    			{
    				cout << endl << endl;
    				cout << "You have failed to comply, encryption terminated!" << endl;
    				cin.get();
    				return 4;
    			}
    		}
    		if(infile.empty())
    		{
    			cout << endl << endl;
    			cout << "How can i encrypt this file \"" << infile << "\" if it does not exsist?" << endl;
    			cin.get();
    			return 5;
    		}
    		if(outfile.empty())
    		{
    			cout << endl << endl;
    			cout << "How can i save to this file \"" << outfile << "\" if you dont specify one?" << endl;				cin.get();
    			return 5;
    		}
    		if(infile == outfile)
    		{
    			outfile+=".enc";
    		}
    		
    		ifstream in(infile.c_str(), ios::binary);
    	
    		if(in.fail())//Makes sure both file have been opened before continuing
    		{
    			cout << endl << endl;
    			cout << "I couldnt locate your file, I am sorry." << endl;
    			cout << "The error is related to this entry : ";
    			cout << infile << endl;
    			cin.get();
    			return 2;
    		}
    
    		ofstream out(outfile.c_str(), ios::binary);
    		if(out.fail())
    		{
    			cout << endl << endl;
    			cout << "I was unable to create a output file, I am sorry." << endl;
    			cout << "The error is related to this entry : ";
    			cout << outfile << endl;
    			cin.get();
    			return 2;
    		}
    
    		int i = 0;
    		int q = 0;
    		char letter;
    		char changed1;
    		char junkletter;
    		while( in.read( (char*)&letter, sizeof(letter) ))//read one character till end of the file
    		{
    			changed1 = letter;
    			q++;
    			if((i+3) > keysize)//make sure we wont be overstepping the bound of our keysize
    			{
    				i = 0;
    			}
    			changed1 -= mykey[i];
    			i++;
    			changed1 += mykey[i];
    			i++;
    			changed1 -= mykey[i];
    			i++;
    			out.write( (char*)&changed1, sizeof(changed1) );//output the character to the new file
    			if(q == mykey[i])//if q is equal to a character in the key, it time to put a junk character
    			{
    				q = 0;
    				junkletter = (changed1+mykey[i+2]);//create the junk character
    				out.write( (char*)&changed1, sizeof(changed1) );//out put the junk character
    			}
    		}
    		in.close();
    		out.close();
    	}
    	else //Load Decrypt Section
    	{
    		cout << "Enter your key : ";
    		getline(cin, mykey, '\n');
    		cout << "Location of the encrypted file, Ex \"c:/myfile.txt\" : ";
    		getline(cin, infile, '\n');
    		cout << "Location to save decrypted file, Ex \"c:/myoutfile.txt\" : ";
    		getline(cin, outfile, '\n');
    		int keysize2 = mykey.size();
    
    		if(keysize2 <= 7)
    		{
    			mykey.clear();
    			cout << endl << endl;
    			cout << "Your key was to short, here is a chance to fix that." << endl;
    			cout << "Enter a Key : ";
    			getline(cin, mykey, '\n');
    			keysize2 = mykey.size();
    			if(keysize2 <= 7)
    			{
    				cout << endl << endl;
    				cout << "You have failed to comply, encryption terminated!" << endl;
    				cin.get();
    				return 4;
    			}
    		}
    		if(infile.empty())
    		{
    			cout << endl << endl;
    			cout << "How can i decrypt this file \"" << infile << "\" if it does not exsist?" << endl;
    			cin.get();
    			return 5;
    		}
    		if(outfile.empty())
    		{
    			cout << endl << endl;
    			cout << "How can i save to this file \"" << outfile << "\" if you dont specify one?" << endl;
    			cin.get();
    			return 5;
    		}
    		ifstream in2(infile.c_str(), ios::binary);
    	
    		if(in2.fail())//Makes sure both file have been opened before continuing
    		{
    			cout << endl << endl;
    			cout << "I couldnt locate your file, I am sorry." << endl;
    			cout << "The error is related to this entry : ";
    			cout << infile << endl;
    			cin.get();
    			return 2;
    		}
    
    		ofstream out2(outfile.c_str(), ios::binary);
    		if(out2.fail())
    		{
    			cout << endl << endl;
    			cout << "I was unable to create a output file, I am sorry." << endl;
    			cout << "The error is related to this entry : ";
    			cout << outfile << endl;
    			cin.get();
    			return 2;
    		}
    
    		int i2 = 0;
    		int q2 = 0;
    		char letter2;
    		char shanged1;
    		while( in2.read( (char*)&letter2, sizeof(letter2) ) )//read one character till end of the file
    		{
    			q2++;
    			shanged1 = letter2;
    			if((i2+3) > keysize2)//make sure we wont be overstepping the bound of our keysize
    			{
    				i2 = 0;
    			}
    			
    			shanged1 += mykey[i2];
    			i2++;
    			shanged1 -= mykey[i2];
    			i2++;
    			shanged1 += mykey[i2];
    			i2++;
    
    			out2.write((char*)&shanged1, sizeof(shanged1));//output the character to the new file
    			if(q2 == mykey[i2])
    			{
    				q2 = 0;
    				in2.read( (char*)&letter2, sizeof(letter2) );//discard the junk character
    			}
    		}
    		in2.close();
    		out2.close();
    	}
    	cout << "HAHA I have completed your tasks, may I have another!" << endl;
    	cin.get();
    	return 0;
    }

  7. #37
    Banned
    Join Date
    Jun 2005
    Posts
    594
    dealine has passed or is about to depending on your time zone
    and what you ment by dealine!!

    who is the winner, and what do i get

  8. #38
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    ceazar

    Quote Originally Posted by kryptkat
    Fkulvwldqv 0 Nlwwbc 4 !!!!
    Christians 0 Kittyz 4 !!!!

    no zip uploads? and 97kb limit?


    Code:
             case IDC_CeazarEncrypt:
                        for(a=0;a< (textlen +1) ; a++ ) {
                         
                      if(  ( ( buff[a] ) > 96 ) && (  ( buff[a] ) < 123 )  ) {
                           tempbuff[a] = lowtest( buff[a] , atoi(keybuf) );
                                                                          }
    
                     else if(  ( ( buff[a] ) > 64 ) && (  ( buff[a] )  < 91 ) {
                             tempbuff[a] = hightest( buff[a] , atoi(keybuf) );
    
                                                  }
    
                    else
                            { 
                           tempbuff[a] = buff[a];
                            }                  
     };   
     SetDlgItemText(hwnd, IDC_TEXTB, tempbuff  ) ; 
    
                             GlobalFree((HANDLE)buff);
                                                                            }
    
                                                                    break;
     
    
    --------
    
                                                             case IDC_CeazarDeCrypt:
    
    
    
                  for(a=0; a < (textlen +1) ; a++ ) {
                                                     if(  ( ( buff[a] ) > 96 ) && (  ( buff[a] ) < 123 )  ) { tempbuff[a] = delowtest( buff[a] , atoi(keybuf) ); }
    
             else if(  ( ( buff[a] ) > 64 ) && (  ( buff[a] ) < 91 )  ) {
                                                                                                              
              tempbuff[a] = dehightest( buff[a] , atoi(keybuf) );    }
    
    
              else
                      {
                           tempbuff[a] = buff[a];
                         }   
                 };
    
         SetDlgItemText(hwnd, IDC_TEXTB, tempbuff  ) ; 
    
             GlobalFree((HANDLE)buff);
                                                                            }
    
                                                                    break;
    Last edited by kryptkat; 07-31-2005 at 12:17 PM.

  9. #39
    *this
    Join Date
    Mar 2005
    Posts
    498
    Ill allow late submissions seeing as I only recieved one...

  10. #40
    *this
    Join Date
    Mar 2005
    Posts
    498
    Late submissions are still valid, if there isnt enough space email it to me:
    [email protected]

    The results will be posted in a week.
    Thanks for everyone that participated!

  11. #41
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    if ne one would like to see meow entry...

    http://www.tekcities.com/kitty/index.html

    still had logic error 209kb zipped halfmeg unzip

  12. #42
    *this
    Join Date
    Mar 2005
    Posts
    498
    Ok, now that we have more entries it will take longer for testing so please allow me another week.

    Thanks,
    Josh

  13. #43
    *this
    Join Date
    Mar 2005
    Posts
    498
    Well I'm just about done, sorry it took so long I've been on vacation for a while.

  14. #44
    Banned
    Join Date
    Jun 2005
    Posts
    594
    ive been very anxious , how many submission did you
    end up recieving?

  15. #45
    *this
    Join Date
    Mar 2005
    Posts
    498
    Not many, ya sorry ive been really busy so its hard to sit down and look closely at them. I think i have 3 submissions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM
  2. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM
  3. Encryption Cracking Contest
    By vasanth in forum C++ Programming
    Replies: 51
    Last Post: 04-16-2002, 09:55 PM