Code.GeekInterview.com
 
Code Samples C
 

String Encryption


Code ResourceAuthor: kaivalya1989  

Difficulty Level: Intermediate

Published: 5th Sep 2008   Read: 6422 times  

Filed in: C
Add Comment


 

 

Sponsored Links


 

 

This code explains how data encryption and decryption can be done in C.

 


Sample Code
  1. //program to code and decode a given string:
  2.  #include<stdio.h>
  3.  #include<conio.h>
  4.  
  5.  void main()
  6.  {
  7.  char s1[]="I love my country india";
  8.  char s2[30],s3[30];
  9.  clrscr();
  10.  printf("Original string is:n");
  11.  printf("%s",s1);
  12.  code(s1,s2);
  13.  printf("ncoded string is:");
  14.  printf("n%s",s2);
  15.  
  16.  decode(s2,s3);
  17.  printf("ndecoded string is:");
  18.  printf("n%s",s3);
  19.  getch();
  20.  }
  21.  
  22.  code(s,t)
  23.  char *s,*t;
  24.  {
  25.  while(*s)
  26.  {
  27.  *t=*s+127;
  28.  t++;
  29.  s++;
  30.  }
  31.  }
  32.  
  33.  decode(s,t)
  34.  char *s,*t;
  35.  {
  36.  while(*s)
  37.  {
  38.  *t=*s-127;
  39.  t++;
  40.  s++;
  41.  }
  42.  }
Copyright GeekInterview.com


Next Article: 10 x 10 Mulplication Table


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

this program does not run on turbo c.
Comment posted by: relith on 2010-09-07T20:09:05
pls send output for this program
Comment posted by: ramya on 2011-02-19T01:24:03

Popular Coders

# Coder NameHits
1. kaivalya198933896
2. mano.mithun21571
3. deepu0817850
4. meefriend4ever8112
5. chandrikakr8081
6. sadasivathavamani7318
7. shashivaishnav7139
8. venkatakrishnansvpr7044
9. Jimmy Zorald6685
10. sripri5701

Active Coders

Refined Tags