Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples C
 

Modified String Encryption


Code ResourceAuthor: reliable  

Difficulty Level: Intermediate

Published: 13th Mar 2009   Read: 1094 times  

Filed in: C
Add Comment


 


Program to code and decode a given string
 


Sample Code
  1. /*
  2.  *  ModStringEncrytion.c
  3.  *
  4.  *  Description: Program to code and decode a given string
  5.  *  Created on: Mar 12, 2009
  6.  *  Author: Reliable
  7.  *  Original Code: http://code.geekinterview.com/c/string-encryption.html
  8.  *  Updates: Modified to make take in effect the '' at the end
  9.  *
  10.  */
  11.  
  12. #include <stdio.h>
  13.  
  14. void code(char *s,char *t)
  15. {
  16.         while(*s)
  17.         {
  18.                 *t=*s+127;
  19.                 t++;
  20.                 s++;
  21.                 if(*s == '')
  22.                         *t=*s;
  23.         }
  24. }
  25.  
  26. void decode(char *s,char *t)
  27. {
  28.         while(*s)
  29.         {
  30.                 *t=*s-127;
  31.                 t++;
  32.                 s++;
  33.                 if(*s == '')
  34.                         *t=*s;
  35.         }
  36. }
  37.  
  38. void main()
  39. {
  40.         char s1[]="I love India";
  41.         char s2[30],s3[30];
  42.  
  43.         printf("Original string is:n");
  44.         printf("%s",s1);
  45.         code(s1,s2);
  46.         printf("ncoded string is:");
  47.         printf("n%s",s2);
  48.  
  49.         decode(s2,s3);
  50.         printf("ndecoded string is:");
  51.         printf("n%s",s3);
  52.  
  53. }
Copyright GeekInterview.com


Next Article: Glittering Circle


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. kaivalya198914892
2. chandrikakr4781
3. meefriend4ever3547
4. sripri2893
5. deepu082813
6. Jimmy Zorald2562
7. Rajani1630
8. norman1442
9. reliable1095

Active Coders

# Coder NameCodes
1. kaivalya19894
2. sripri1
3. Jimmy Zorald1
4. norman1
5. Rajani1
6. meefriend4ever1
7. chandrikakr1
8. reliable1
9. deepu081

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape