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.

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

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 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 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 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.
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
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
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 - 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
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
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 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
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
ASCII values table
ASCII values table          ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII
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
code
code  code for android sample program
Code
Code  how to print this?? with the use of only JSP....... 1 23 456 78910   Here is the jsp number pattern example: 1 2 3 4 5 6 7 8 9 10 <%@page language="java"%> <% int k = 1; for(int i=1; i<= 4 ;i
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance
code
code  write a program to encrypt and decrypt the cipher text "adfgvx"   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import
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
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
ModuleNotFoundError: No module named 'advent-of-code-sample'
ModuleNotFoundError: No module named 'advent-of-code-sample'  Hi...: No module named 'advent-of-code-sample' How to remove the ModuleNotFoundError: No module named 'advent-of-code-sample' error? Thanks   Hi
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
This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new
This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new
print this image in java code using only loop{for, if, loop}
print this image in java code using only loop{for, if, loop}  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  ... is a code that displays the following pattern
J2ME code hint - MobileApplications
J2ME code hint  I am required to make a mobile application for encryption and decryption of sms messages using RSA. The last day for submission is 9th of March, 2009... If anyone can plz help me in this regard plz let me
How to use Bean Area in Oracle Forms 9i with Sample code ?
How to use Bean Area in Oracle Forms 9i with Sample code ?  Hi friend.I posted a query,but I didn't get the answer for it.Help me to resolve including a bean area in oracle forms 9i and using it in forms.Thanks in advance.Help me
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
JSP Encryption - JSP-Servlet
JSP Encryption  Hi! Please give me code for MD5 encryption & decryption. Thanks in advance

Ads