VB icon

Text encrypter

Email
Submitted on: 1/1/2015 9:41:00 AM
By: Evan Hartman (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: C
Views: 1106
 
     *UPDATED* Now uses a more recursive and less pattern oriented algorithm. Basically encrypts a text type file using a simple recursive character shift techinque. Pretty basic, but powerful.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Text encrypter
//**************************************
conio.h
stdio.h
stdlib.h
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Text encrypter
// Description:*UPDATED* Now uses a more recursive and less pattern oriented algorithm.
Basically encrypts a text type file using a simple recursive character shift techinque. Pretty basic, but powerful.
// By: Evan Hartman (from psc cd)
//
// Inputs:Takes an input file name, an output file name, and a key
//
// Returns:creates(or over-writes) an output file
//
// Side Effects:This program will automatically overwrite any file that you specify as the output file
//**************************************

#include	<stdio.h>
#include	<conio.h>
#include	<stdlib.h>
#include	<math.h>
FILE	*stream;
FILE	*streamout;
//	The key can be up to 100 characters,
//	will accept and use spaces, and is
//	case sensitive. The only way to decypher
//	the file is to know the key. Kinda neat,
//	because even if you know the algorithm,
//	it doesn't do you any good.
int main(int argc, char *argv[]){
	char			y;
	int				x;
	int				z;
	int				i;
	unsigned char	input[100];
	unsigned char	output[100];
	unsigned char	key[100];
	
	printf("Enter Input Filename -> ");
	scanf("%s",input);
	printf("Enter Output Filename -> ");
	scanf("%s",output);
	getchar();
	printf("Enter Key -> ");
	scanf("%[^\n]",key);
	stream=fopen(input,"r");
	streamout=fopen(output,"w");
	z=1;
	do{
		y=fgetc(stream);
		if(y!=EOF){
			x=(int)y;
			for(i=0;key[i];i++)
				x=x^key[i];
			x^=z;
			z^=2^z;
			fprintf(streamout,"%c",x);
		}							
	}while(y!=EOF);					
	fclose(stream);
	fclose(streamout);
	printf("press any key to continue");
	while(!kbhit());//wait to exit
	return 0;
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.