Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Security Sample code for An ASCII Encryption and Decryption code in C-language only.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


William Briggs
Sample code for An ASCII Encryption and Decryption code in C-language only.
1 Answer(s)      3 years and 5 months ago
Posted in : Security


In an environment where security is paramount, the messages stored in a file must have a format that is different from the meaning of the original message. Each character has a number in the ASCII chart. The messages stored in a file should be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show that the word still continues. When a space is encountered, add a word space. Change word by word until the end of the message which is later stored in a file. This is called encryption. When one wants to read the contents of the file, It should display the encrypted form and also the original version. Changing the copy to the original will be called decrypting. Eg

The cat is translated to 84w104w101space99w97w116 (hint: try printf("%d",'t');) Create code for this project including both the encryption and decryption aspects in ASCII format and only in C (NOT EVEN C++). Thank you.Please if possible post answers also to


Advertisement
View Answers

July 19, 2011 at 5:43 PM


#include<stdio.h>

void main(){
    FILE *fp1,*fp2;
    int choice;
    char fname[20],temp[20]={"file.txt"},c;
    clrscr();
    printf("Press 1 to Encrypt");
    printf("Press 2 to Decrypt");
    printf("Enter your Choice:");
    scanf("%d",&choice);

    switch(choice){
    case 1:
    printf("Enter the filename to Encrypt:");
    scanf("%s",fname);
    fp1=fopen(fname,"r+");
    if(fp1==NULL) {
         printf("The file %s can't be open",fname);
         getch();
         exit();
    }
    fp2=fopen(temp,"w+");
    if(fp2==NULL){
         printf("The file Temp can't be open");
         getch();
         exit();
    }
    c=fgetc(fp1);
    while(c!=EOF){
         fputc((c+fname[0]),fp2);
         printf("%c",c+fname[0]);
         getch();
         c=fgetc(fp1);
    }
     fclose(fp1);
     fclose(fp2);
     remove(fname);
     rename(temp,fname);
     printf("The file is Encrypted:");
     getch();
     break;

     case 2:
     printf("Enter the Filename to Decrypt:");
     scanf("%s",fname);
     fp1=fopen(fname,"r+");
     fp2=fopen(temp,"w+");
     c=fgetc(fp1);
     while(c!=EOF){
         fputc(c-fname[0],fp2);
         c=fgetc(fp1);
     }
     fclose(fp1);
     fclose(fp2);
     remove(fname);
     rename(temp,fname);
     printf("The file is decrypted:");
     getch();
  }
}


Related Tutorials/Questions & Answers:
Sample code for An ASCII Encryption and Decryption code in C-language only.
Sample code for An ASCII Encryption and Decryption code in C-language only... code for this project including both the encryption and decryption aspects in ASCII format and only in C (NOT EVEN C++). Thank you.Please if possible post
servelt -jsp Encryption Decryption Code
servelt -jsp Encryption Decryption Code  Encryption code&Decryption code Iam developing a web security application for that reason i need a code of encryption &Decryption in servlet. Can u please send it to me.Its very
Advertisements
c language code
c language code  Dear Sir, Could you send me the c language codings for BOOK BANK
encryption and decryption of files
encryption and decryption of files   Please can any one provide me with the code for encryption and decryption of files using RSA algorithm. I want to use a browse option to search for the file which is needed for encryption
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop... be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop... be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop... be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show.... This is called encryption. When one wants to read the contents of the file
encryption and decryption
encryption and decryption   ASCII encryptor I want to develop... be in the corresponding ASCII format. And if it?s a word, concatenate a letter w to show.... This is called encryption. When one wants to read the contents of the file
decryption and encryption - Java Beginners
decryption and encryption  hi everyone. my question is that i have one problem which i have to solve and the issue is that i have to do the encryption and decryption thing there in my code, e.g if the user enters the abc the code
encryption and decryption
encryption and decryption  how to encrypt and decrypt data in text file
Encryption Decryption
Encryption Decryption  I want to store a type string to my database, specifically MSSQL, I want the stored data in the database to be encrypted and I want to retrieve it in it's decrypted format. I am using JSP's, I want
Encryption code - JSP-Servlet
Encryption code  Iam developing a web security application for that reason i need a code of encryption in servlet. Can u please send it to me.Its very urgent Because my project delivery date is very near
Encryption Decryption In Scriptlets/Java
Encryption Decryption In Scriptlets/Java  I have this code in my scriptlet, when I use the Encryption code to encrypt my data it executes... where the program stopped working and it stopped in the decryption part and I get
Encryption and Decryption - Java Beginners
the source code of encyption and decryption using java. Thanking you... ...Encryption and Decryption  Hello sir, i need Password encryption and decryption program using java program. I dont know how to write the program
encryption and decryption - Java Beginners
encryption and decryption  i need files encryption and decryption program using java. but i dont know how to write the program.pls help me thank you so much  Hi Friend, Try the following code: import java.io.
Password encryption and decryption
Password encryption and decryption  Hello, I'm developing a system that requires user to login to enter the system. so I wanted to store encrypted...; For the above code, we have create a database table: CREATE TABLE `user
sample code - WebSevices
sample code  Hi Guys, can any body tell me use of webservices ? I want a sample code using xml with one application server bea weblogic and webserver tomcat   Hi Friend, Please visit the following link
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
Sample Code - Development process
Sample Code   Hi Friend, Give sample code DTO... a new class for each DTO. 2.Write or generate the code for the data transfer class. DataSet is part of the .NET library, so you do not have to code
Sample Ajax Code
Sample Ajax Code  Sample Ajax Code for getting values from another JSP   The below code is helpful to access another Action class //In Main JSP file var xmlHttpObj,xmlHttpObj1; function getXmlHttpObject() { var
Sample Code For ArrayLlist - Java Beginners
Sample Code For ArrayLlist   Hi Friend, I want sample code for adding single records and multiple records using ArrayList.Give sample code for Arraylist with realtime application.  Hi I
need a Sample code - Development process
need a Sample code  i want run the python script in java code by using Runtime class and output should be formed like XML format.please help me. Advanced Thanks, Krishna
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
ASCII values table
ASCII values table          ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII
java sample code - Java Beginners
java sample code  hai...... i need a full sample program fo inheritance.........  Hi Friend, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Thanks
Sample Code for DTO in WebApplication - Development process
Sample Code for DTO in WebApplication   Hi Friends, Can u explain DTO in webapplication with sample code
What is ASCII?
; ASCII, the abbreviation of  the American Standard Code for Information... of  C. ASCII has been very popular in the computer world. It ... character sets. Nowadays Unicode character set is replacing ASCII code very rapidly
Hibernate sample code - Hibernate Interview Questions
Hibernate sample code  Hi Can any body tell me how to persist inner... Hibernet.org.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines... applications that only uses the stored-procedures to implement the business logic
JSP Encryption - JSP-Servlet
JSP Encryption  Hi! Please give me code for MD5 encryption & decryption. Thanks in advance
C language
C language  i want that when i hit any key only * to be print not the hit key in c language   The given example will display aestricks on hitting any key. #include "stdio.h" #include "conio.h" #include "ctype.h" int
C Language
C Language  What's the right declaration for main()? Is void main() correct? in C language ? please help me sir ! Thank You
Advertisements
 

 

 

DMCA.com