| | |
Why does this not work?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
•
•
•
•
Thanks for your help.
I was wondering how I could use a algorithm library with this and which one to use.
Also the password part still does not work with my compiler I don't know it it worked with yours or not.
Regarding algorithm, I don't know where you are thinking about using it, so I have no idea how to answer your question. There are all sorts of ways to improve the program. I suppose you could use algorithm possibly. I can't see, off the top of my head, where you would use it here. This program just replaces each character with a different character using a Caesar Cipher.
http://en.wikipedia.org/wiki/Caesar_cipher
•
•
Join Date: Mar 2009
Posts: 27
Reputation:
Solved Threads: 0
Ok I need to get a few things straight.
1 The reason there is a password is because it is a encryption program and if it didn't have a password someone could just use it and get my algorithm.
2 The reason it is a .dll file is for the exact reason you said to confuse people so they don't think it is a password file, and I am hoping once I get the password part working to make the password get encrypted.
3 I removed the comment tags already(I am not that stupid).
So what I need to do is:
1 Get the password protection working.
2 Make the password get encrypted, and set up the program so the password file cant just be deleted to make a new password.
3 Add an algirithum like acr4 to the encrypting and decrypting part.
Using a .h header file or some .lib file.
Sorry if I sound rude but I have only been doing c++ 3 years and am only a beginner getting frustrated.
Thank you very much.
1 The reason there is a password is because it is a encryption program and if it didn't have a password someone could just use it and get my algorithm.
2 The reason it is a .dll file is for the exact reason you said to confuse people so they don't think it is a password file, and I am hoping once I get the password part working to make the password get encrypted.
3 I removed the comment tags already(I am not that stupid).
So what I need to do is:
1 Get the password protection working.
2 Make the password get encrypted, and set up the program so the password file cant just be deleted to make a new password.
3 Add an algirithum like acr4 to the encrypting and decrypting part.
Using a .h header file or some .lib file.
Sorry if I sound rude but I have only been doing c++ 3 years and am only a beginner getting frustrated.
Thank you very much.
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
•
•
•
•
Ok I need to get a few things straight.
1 The reason there is a password is because it is a encryption program and if it didn't have a password someone could just use it and get my algorithm.
2 The reason it is a .dll file is for the exact reason you said to confuse people so they don't think it is a password file, and I am hoping once I get the password part working to make the password get encrypted.
3 I removed the comment tags already(I am not that stupid).
So what I need to do is:
1 Get the password protection working.
2 Make the password get encrypted, and set up the program so the password file cant just be deleted to make a new password.
3 Add an algirithum like acr4 to the encrypting and decrypting part.
Using a .h header file or some .lib file.
Sorry if I sound rude but I have only been doing c++ 3 years and am only a beginner getting frustrated.
Thank you very much.
There's a difference between confusing people who are trying to debug your code and confusing people who are trying to break your encryption. Get the program correct first, then you can obfuscate the code all you want. The obfuscation comes later. Anyone who had the source code could immediately see that you aren't loading a dll, despite the name. It's not going to trick anyone. Anyone who had the source code will also see that your key is hard-coded into the code. Don't confuse your "key" with the "password" stored in your text file. The password stored in the file has nothing to do with the encryption and decryption. It simply aborts the program if you don't have the right program. You also have the password file hard-coded in the file, so anyone with the source code knows immediately where to look. If you want security, you need to have the key and/or password read in as command line arguments. That way you can have the source code and you still won't know what the key is and where the pssword is stored. Anyone with the source code immediately can bypass the password anyway, so all you're left with is the key.
Regarding comments and names, normally the bad guy trying to revese engineer your program won't have the source code. They have the executable. You keep the source code close to the vest. All comments and names are stripped out of the executable anyway by the compiler. Comment all you want, name everything whatever you want and it's all irrelevant because you only release the executable.
A good encryption/decryption program/algorithm allows you to be completely transparent with the source code. Use an algorithm like Triple DES or AES and I can show you my source code and you still can't break it without the key. I was assuming that since this is a Caesar Cipher, this project was just for fun since no one actually uses that since it's way too easy to break.
Anyway, we have no way of knowing where you're coming from when you post if you don't tell us in the beginning. We're assuming that you're trying to create good, well-organized easy-to-follow code. As mentioned, if you want security, don't hard-code the key, password, or password file. Read them in as command line arguments or ask them to type it in. Or I suppose you could have a hash function and hash a password and hard-code the hash value into the program. A good hash formula won't allow you to go backwards from the hash to the password.
•
•
Join Date: Mar 2009
Posts: 27
Reputation:
Solved Threads: 0
That sounds like great stuff.
But there is a problem I know what your talking about but I do not know how to put it in to code.
I know you don't have time to code this for me but could you give me some help?
My friend and I are competing we each have a encryption program and mine when we started was way ahead of his but now his is using all the stuff you are talking about he's using hash to store the password and no hard coded stuff.
But he has it so much easier, he is using Python.
What can I do?
Thanks.
But there is a problem I know what your talking about but I do not know how to put it in to code.
I know you don't have time to code this for me but could you give me some help?
My friend and I are competing we each have a encryption program and mine when we started was way ahead of his but now his is using all the stuff you are talking about he's using hash to store the password and no hard coded stuff.
But he has it so much easier, he is using Python.
What can I do?
Thanks.
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
Well, here's the program I posted earlier using command line arguments and adding the password stuff back in.
Compile it. Think of a key like 1, 2, 3, 4, whatever. Create a password file in a text editor called ""setpCS4.dll" or whatever you want to call it, then run it like this (assuming your program is called "encryptionProgram.exe" and your password file is "setupCS4.dll" and your key is 5):
I left the decryption bug in there that I told you about earlier. Again, pick an easy file like "jklm" and an easy key like 1, then encypt it and see what it looks like. Now decrypt it and note the problem and what is happening. Line 127 and 130 are where the program grabs the command line arguments.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> #include <string> #include <cstdlib> using namespace std; string str; void Message() { cout <<"*-----------------------------------*\n" <<"| Welcome to Crypto! |\n" <<"*-----------------------------------*\n"; cout <<"Please type a command.\n" <<"Type \"m\" for the command menu.\n"; return; } void Encrypt(char *filename, int key) { system("CLS"); ifstream in; ofstream out; char c; string fileContent; in.open(filename); if(in.fail()) { in.close(); cout <<"Could not find file: "<<filename<<endl; system("PAUSE"); system("CLS"); Message(); return; } while(in.get(c)) { fileContent += c; } in.close(); for(size_t i = 0; i < fileContent.size(); i++) { fileContent[i] += key; } out.open(filename, ios::trunc); out << fileContent; out.close(); cout <<"FILE ENCRYPTED!\n"; system("PAUSE"); system("CLS"); Message(); } void Decrypt(char *filename, int key) { system("CLS"); ifstream in; ofstream out; char c; string fileContent; in.open(filename); if(in.fail()) { in.close(); cout <<"Could not find file: "<<filename<<endl; system("PAUSE"); system("CLS"); Message(); return; } while(in.get(c)) { fileContent += c; for(size_t i = 0; i < fileContent.size(); i++) { fileContent[i] -= key; } } in.close(); out.open(filename, ios::trunc); out << fileContent; out.close(); cout <<"FILE DECRYPTED!\n"; system("PAUSE"); system("CLS"); Message(); } bool PasswordCheck (char* filename) { ifstream file_in(filename); char pass[80]; char input_line[80]; if (! file_in) { file_in.close(); return false; } cout <<"Please type your password: "; cin.getline(pass, 80); while( file_in.getline(input_line, 80) ) { if(strcmp(input_line, pass) == 0) return true; } return false; } int main(int argc, char* argv[]) { char filename[20]; char comd; int key = atoi (argv[1]); if (!PasswordCheck (argv[2])) { cout << "Bad password. Exiting program.\n"; return 0; } system("CLS"); cout <<"*-----------------------------------*\n" <<"| Welcome to Crypto! |\n" <<"*-----------------------------------*\n"; cout <<"Please type a command.\n" <<"Type \"m\" for the command menu.\n"; while(true) { cin >> comd; switch(comd) { case 'e' : system("CLS"); cout <<"Please type name of file to encrypt (.txt): "; cin >> filename; Encrypt(filename, key); break; case 'd' : system("CLS"); cout <<"Please type name of file to encrypt (.txt): "; cin >> filename; Decrypt(filename, key); break; case 'm' : cout <<"\n<COMMAND MENU>\n" <<"*--------------------*\n" <<"| e = 'Encrypt' |\n" <<"| d = 'Decrypt' |\n" <<"| m = 'Command Menu' |\n" <<"| q = 'Quit' |\n" <<"*--------------------*\n"; break; case 'q' : cout <<"\nThanks For Using 'Crypto'\n"; system("PAUSE"); return 0; break; default : break; } } }
Compile it. Think of a key like 1, 2, 3, 4, whatever. Create a password file in a text editor called ""setpCS4.dll" or whatever you want to call it, then run it like this (assuming your program is called "encryptionProgram.exe" and your password file is "setupCS4.dll" and your key is 5):
encryptionProgram 5 setupCS4.dll I left the decryption bug in there that I told you about earlier. Again, pick an easy file like "jklm" and an easy key like 1, then encypt it and see what it looks like. Now decrypt it and note the problem and what is happening. Line 127 and 130 are where the program grabs the command line arguments.
![]() |
Similar Threads
- Need 2 techies for tech-support, work from home (Tech / IT Consultant Job Offers)
- Requesting shadowing work at home job (Software Development Job Offers)
- 3D Engine Developer Needed from India - Work from home (Web Development Job Offers)
Other Threads in the C++ Forum
- Previous Thread: Command Line Arguments(CLA)
- Next Thread: 1540-0063 (S) The text "eventqueue_t" is unexpected.
| Thread Tools | Search this Thread |
+ 2007 account add assembly blackmail block browser buttons c# c++ challenge char character click code compression computer control cool crack csv data dell design desktop ect email encryption enterprise excel explorer facebook favouriteforums file firefox form funny game generated government growth guess guessing hardware interface java karmic kioti16 kmip koala laptop linked linkedin linux list login microsoft mssqlbackend netbeans news number object opensource os panel password php program programing prompt protection ps3 research rsa save security session simple single size softwaredevelopment string sun super survey test time torvalds troubleshoot twitter ubuntu user useraccounts view vista webmail windows word xp







