Sample code for An ASCII Encryption and Decryption code in C-language only.

Ads
 

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();
  }
}

Ads









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
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
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
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
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
code
code  code for android sample program
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
ASCII values table
ASCII values table          ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII
Code
Code  code for connecting c lang to database
code
code    how to write this in java
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  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  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
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

Ads