Add to Favorites    Make Home Page 1183 Online  
 Language Categories  
 Our Services  

Home » C++ Home » File Manipulation Home » saurabh

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title saurabh
Author saurabh
Author Email sid_isin [at] yahoo.com
Description his Program Will Encrypt And Decrypt Any File
Provides The Maximum Security
Category C++ » File Manipulation
Hits 389981
Code Select and Copy the Code
/* Written By : Saurabh Jain I Year B.sc (Hons) Computer Science College Of Vocational Studies Delhi University This Program Will Encrypt Or Decrypt Ant Text Document Its A Complete Bug Free Program If Modified Please Send To : [email protected] */ /* This Program Will Encrypt Any Type Of Text Document */ #include<fstream.h> #include<conio.h> #include<stdio.h> int main() { char name[30],target[30],ch,mod; //Declare Variables int num[100],i,option; cout<<"Enter Your Option "; cout<<" 1. To Encrypt The File "; cout<<" 2. To Decrypt The File "; cout<<" Option : "; cin>>option; if(option==1) { cout<<"Enter The Path Of A File Which Is To Be Encrypted : "; gets(name); ifstream fin(name,ios::binary); //Open The Input File In A Binary Mode if(!fin) { //Show Error Occur If File Does Not Exist cout<<" Error In Openinig Of A File : "; //Or Any Error Occurs return 1; } cout<<" Enter The New Encrypted File Name : "; gets(target); ofstream fout(target,ios::binary); //Open The OutPut File In A Binary Mode if(!fout) { cout<<" Error In Opening Of Target File : "; //Show Error If Any Error Occrs In Opening Of A File return 1; } for(i=0;i<9;i++) { //Multiple For Loops For Storing The Numbers num[i]=i; //In An Array } for(i=14;i<31;i++) //Loops Will Store 100 Numbers { num[i-5]=i; //Which Will Encrypt The Contents Of A File } for(i=33;i<=68;i++) //To Avoid The Error Ocuur Caused By The { //Enter Key , Tab Key & Space Key num[i-7]=i; //These Variations In Loops Is Made } for(i=97;i<=122;i++) { num[i-35]=i; } while(fin) { //Open The Input File fin.get(ch); if(ch==EOF)break; //Exit To Loop When End Of File if((ch>=97) && (ch<=122)) { //Encrypt The Small Letters i=97; mod=num[ch-i]; fout<<mod; } if((ch>=65) && (ch<=90)) { i=39; //Encrypt The Capital Letters mod=num[ch-i]; //And Store In An Output File fout<<mod; } if((ch>=48) && (ch<=57)) { i=4; //Encrypt The Numbers mod=num[ch+i]; fout<<mod; } if((ch==10)||(ch==13)) { mod=ch; //For Enter Key fout<<mod; } if(ch==32) fout<<ch; //For Space Key if(ch==9) fout<<ch; //For Tab Key if((ch>=33)&&(ch<=47)) { //For Special Symbols mod=ch+64; fout<<mod; } if((ch>=58)&&(ch<=64)) { //For Special Symbols mod=ch+54; fout<<mod; } if((ch>=91)&&(ch<=96)) { mod=ch+28; //For Special Symbols fout<<mod; } if((ch>=123)&&(ch<=126)) { mod=ch-40; //For Special Symbols fout<<mod; } } fin.close(); //Close The Input File fout.close(); //Close The Output File cout<<" Your File Is Encrypted Now........... "; getch(); return 0; } /*======================================================================== =======================================*/ /* This Program Will Decrypt The Document */ if(option==2) { char name[30],target[30],ch,mod; //Declare Variables int num[100],i,flag; cout<<"Enter The Path Of A File Name Which Is To Be Decrypted : "; gets(name); ifstream fin(name,ios::binary); if(!fin) //Open The Encryped File In A Binary Mode { cout<<"Error In Opening Of A File : "; return 1; //Show Error If File Does Not Exist } //Or Any Occurs In Opening Of A File cout<<" Enter The New Decrypted File Name : "; gets(target); ofstream fout; fout.open(target,ios::binary); //Opens The Output File In An Binary Mode if(!fout) { //Show Error If Any Error Occurs In Opening Of A File cout<<"Error In Opening Of A Target File : "; return 1; } for(i=0;i<9;i++) { //Same Multiple For Loops For Storing The Numbers num[i]=i; //In An Array } for(i=14;i<31;i++) { num[i-5]=i; //Loops Will Store 100 Numbers } for(i=33;i<=68;i++) //Which Encrypts The Document Also Decrypt It { num[i-7]=i; } while(fin) { //Opens The Encryped File fin.get(ch); flag=0; //Turn Off Flag if(ch==EOF)break; for(i=26;i<52;i++) { if(ch==num[i]) //Loop For Match The Small Letters Letters { mod=i+39; //If Match Then Put Appropriate Letter fout<<mod; //In A OutPut File flag=1; break ; //Turn On Flag And Exit The Loop } } if (flag==1) continue ; //If Flag Is On Then Continue Outer Loop for(i=0;i<26;i++) { //Loop For Match The Capital Letters if(ch==num[i]) { //If Match Then Put Appropriate Letter mod=i+97; //In A OutPut File fout<<mod; flag=1;break; //Turn On Flag And Exit From This Loop } } if (flag==1) continue ; //If Flag Is On Then Continue Outer Loop for(i=52;i<62;i++) { //Loop For Numerical Numbers if(ch==num[i]) { mod=i-4; fout<<mod; flag=1; break ; } } if (flag==1) continue ; if((ch==10)||(ch==13)) { mod=ch; //Condition For Enter Key fout<<mod; } if(ch==32) fout<<ch; //Condition For Space Key if(ch==9) fout<<ch; //Condition For Tab Key if((ch>=97)&&(ch<=111)) { mod=ch-64; //For Special Symbols fout<<mod; } if((ch>=112)&&(ch<=118)) { mod=ch-54; //For Special Symbols fout<<mod; } if((ch>=119)&&(ch<=124)) { mod=ch-28; //For Special Symbols fout<<mod; } if((ch>=83)&&(ch<=86)) { //For Special Symbols mod=ch+40; fout<<mod; } } fin.close(); //Close The Encrypted File fout.close(); //Close Your Original Decrypted File cout<<" The File Is Being Decrypted............ "; getch(); return 0; } return 0; }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1115


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review