VB icon

Kodifica

Email
Submitted on: 1/1/2015 6:16:00 AM
By: Jorge Sauri Creus (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: C
Views: 460
 
     This code encrypts any file u want using a bit complement.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Kodifica
// Description:This code encrypts any file u want using a bit complement.
// By: Jorge Sauri Creus (from psc cd)
//
// Inputs:just wirte the input file and output file in command line.
//**************************************

// By: Jorge Sauri Creus
// Jsauri@sureste.com
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void main(int argc, char *argv[])
{
unsigned char car, dump;
FILE *in, *out;
long int i, perc, cont;
i=1;
perc=1;
cont=0;
if ((argc<2) || (argc>3))
	{
	printf(" Usage: CODIFICA <Input_File> [Output_File]\n\n");
	printf(" Where:<Input_File>= File to encrypt \n");
	printf("[Output_File] = Guess...(optional).\n");
	}
if (argc==2) argv[2]=argv[1];
if ((in = fopen(argv[1], "rt"))== NULL)
	{
	fprintf(stderr, "Error openning file.\n");
	return 1;
	}
putchar('\n');
while(!feof(in)) {dump=fgetc(in); cont++;}
fclose(in);
if ((in = fopen(argv[1], "rt"))== NULL)
	{
	fprintf(stderr, "Error openning file.\n");
	return 1;
	}
if ((out = fopen(argv[2], "wt"))== NULL)
	{
	fprintf(stderr, "Write error.\n");
	return 1;
	}
while (!feof(in))
	 {
	i++;
	car=fgetc(in);
	car=~car;
	fputc(car, out);
	perc=(i*100)/cont;
	color(4,0);
	gotoxy(1,wherey());
	cprintf(" %d%% encoded.", perc);
	 }
	gotoxy(1,wherey());
	cprintf(" 100% encoded.");
fclose(in);
fclose(out);
color(7,0);
putchar('\n');
cprintf(" File done.\n\n");
}


Other 2 submission(s) by this author

 


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.