RSS Forums RSS

C++ encryption

Please support our C++ advertiser: Programming Forums
Reply
Posts: 2
Reputation: jase728 has a little shameless behaviour in the past 
Solved Threads: 0
jase728 jase728 is offline Offline
Newbie Poster

C++ encryption

  #1  
Oct 26th, 2008
I need help.
How do you encrypt multiple lines of a text file?




/*********************
*Made by Jase Inc *
*Made in 10/22/2008 *
*Boolean Cryptography*
*Using ^ operator *
*********************/





#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main () {
string line;


ifstream myfile ("text.txt");


char key[65]="jaf#$%skl%#ajlf^%dlkfhasjlk@#dsgsfsfrtw";
//Key that is used during the process
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);

cout << line;





}
myfile.close();
}
cout << endl;





ofstream m1 ("text.txt");

for (int x=0; x<27; x++)
{
line[x]=line[x]^key[x];

cout << line[x];

m1 << line [x];


//Encrypts data and wrties to file
}
cout << endl;



//m1 << "\nwhat is new?";
cout << endl;
m1.close();







return 0;
}

/*********************
*Made by Jase Inc *
*Made in 10/22/2008 *
*Boolean Cryptography*
*Using ^ operator *
*********************/
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,223
Reputation: ddanbe is just really nice ddanbe is just really nice ddanbe is just really nice ddanbe is just really nice 
Solved Threads: 163
ddanbe's Avatar
ddanbe ddanbe is online now Online
Nearly a Posting Virtuoso

Re: C++ encryption

  #2  
Oct 26th, 2008
Set n=0. Read your file per character xor it with your key(n). Increment n. If your key is k chars long(n=k) start again with n=0.
"If you judge people, you have no time to love them." Mother Teresa
Make love, no war. Cave ab homine unius libri.
First rule of debugging: "If you get a different error message, you're making progress."
Danny
Reply With Quote  
Posts: 5
Reputation: dumparun is an unknown quantity at this point 
Solved Threads: 1
dumparun's Avatar
dumparun dumparun is offline Offline
Newbie Poster

Re: C++ encryption

  #3  
Oct 26th, 2008
There are a lot of ways you can do encryption, Just decide which way you want to proceed.. Which mode of operation you want to do. Which sequence you want to follow when you are XOR ing the data. Do you want to add any salt values to the key? Do you want to transform the key to something else? Do you want to follow any standard Algorithm?

Once you decide your strategy, just code that in C++. To start with, i will recommend you to read more on Ecnryption
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the C++ Forum
Views: 633 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:45 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC