943,075 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 978
  • C++ RSS
Oct 26th, 2008
0

C++ encryption

Expand Post »
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 *
*********************/
Similar Threads
Reputation Points: 6
Solved Threads: 0
Newbie Poster
jase728 is offline Offline
2 posts
since Oct 2008
Oct 26th, 2008
0

Re: C++ encryption

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.
Reputation Points: 2023
Solved Threads: 642
Senior Poster
ddanbe is offline Offline
3,733 posts
since Oct 2008
Oct 26th, 2008
0

Re: C++ encryption

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
dumparun is offline Offline
6 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Odd Errors When Compiling Winsock Code.
Next Thread in C++ Forum Timeline: Cant compile single c++ file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC