Hello Helper,
This is my code.
I want to compress the file encrypted and then decrypt the same original file.Can you help ?
/*

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>

#define ENCRYPTION_FORMULA (int)Byte+25
#define DECRYPTION_FORMULA (int)Byte-25

int Encrypt(char *FILENAME,char *NEW_FILENAME)
{
	ifstream fin;
	ofstream fout;
	char Byte;
	char NewByte;

	fin.open(FILENAME,ios::in,ios::binary);
	fout.open(NEW_FILENAME,ios::out,ios::binary);

	if(!fin)
	{
		cout<<"Error in opening the file:"<<endl;
		return 1;
	}

	while(!fin.eof())
	{
		Byte = fin.get();
		if(fin.fail())
		{
			return 0;
		}

		NewByte = ENCRYPTION_FORMULA;
		fout.put(NewByte);
	}

	fin.close();
	fout.close();
	return 1;
}

int Decrypt(char *FILENAME,char *NEW_FILENAME)
{
	ifstream fin;
	ofstream fout;
	char Byte;
	char NewByte;

	fin.open(FILENAME,ios::in,ios::binary);
	fout.open(NEW_FILENAME,ios::out,ios::binary);

	if(!fin)
	{
		cout<<"Error in opening the file:"<<endl;
		return 1;
	}

	while(!fin.eof())
	{
		Byte = fin.get();
		if(fin.fail())
		{
			return 0;
		}

		NewByte = DECRYPTION_FORMULA;
		fout.put(NewByte);
	}

	fin.close();
	fout.close();
	return 1;
}

void main()
{
	clrscr();
	int option;

	char encfile[200];
	char new_encfile[200];
	char new_decfile[200];
	char decfile[200];

	cout<<"Enter 1 to ENCRYPT the file"<<endl;
	cout<<"Enter 2 to DECRYPT the file:"<<endl;
	cout<<"option:"<<endl;
	cin>>option;

	switch(option)
	{
		case 1:
		cout<<"Enter the filename to be encrypted:"<<endl;
		cin>>encfile;
		cout<<"Enter the new filename:"<<endl;
		cin>>new_encfile;
		Encrypt(encfile,new_encfile);
		cout<<"ur file is encrypted now:"<<endl;
		break;

		case 2:
		cout<<"Enter the filename to be decrypted:"<<endl;
		cin>>decfile;
		cout<<"Enter the new filename:"<<endl;
		cin>>new_decfile;
		Decrypt(decfile,new_decfile);
		cout<<"ur file is decrypted now:"<<endl;
		break;
	}

	getch();
}
*/

Thanks And Regards.
kawal

File compression/decompression is a pretty complex task. Here are some free libraries.

File compression/decompression is a pretty complex task.

For that matter, so is encryption. What you're doing barely qualifies; it's a Caesar cipher, which provides no real security. It's fine as a quick and easy substitute in a homework assignment, but you'd never use it in the "real" world.

I want to compress the file encrypted and then decrypt the same original file.

I recommend that you compress first, encrypt second. Encryption usually hides the patterns and structure in data that make compression worthwhile.

Of course, the Caesar cipher you're currently using should compress just as well as the original data, precisely because of one of its weaknesses--it doesn't hide patterns and structure.

How should I proceed to compress and decompress.

sir i am doing mca project in networking ...concept is compress the encrypted file and then decompress and decrypt the same original file..
the file which may be text, image format or any combination which will be implemented in java sir...

which is the best algorithm for compression and encryption the bulk of data...

i need related title for my project sir.........

sir i am doing mca project in networking ...concept is compress the encrypted file and then decompress and decrypt the same original file..
the file which may be text, image format or any combination which will be implemented in java sir...

which is the best algorithm for compression and encryption the bulk of data...

i need related title for my project sir.........

Not enough you hijacked someone else thread in different programming language you are even lazy to ask others to do your work. Use google to search for relevant topics and come back when you have some specific problem, not general query that can be solved by using online search...

You could use one of those open source compression libraries. Last time I needed compression, I used the LZMA SDK.

And with encryption, you haven't specified what sort of encryption are you looking for. The strongest known encryption is AES. There are a few C++ implementations of the said encryption scheme, which you could find out with a Google search.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.