ringneckparrot

Basic Encrypt/Decrypt C Program

Apr 9th, 2012
3,690
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /****************************************************************************
  2.     ringneckparrot (c)
  3.     License: http://creativecommons.org/licenses/by-nc-sa/3.0/
  4.    
  5.     Contact Me:
  6.     Email: ringneckparrot@hotmail.com
  7.     Facebook: http://www.facebook.com/ringneckparrot
  8.     Twitter ID: pp4rr0t
  9.     SecurityTube: http://www.securitytube.net/user/ringneckparrot
  10.  
  11. ****************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16.  
  17. main(int argc, char **argv)
  18. {
  19.     int i;
  20.     char *string;
  21.     char encrypted_string[strlen(string)];
  22.     char decrypted_string[strlen(string)];
  23.     char *key_ch;
  24.     char key_int;
  25.  
  26.     string = argv[1];
  27.     key_ch = argv[2];
  28.     key_int = atoi(key_ch);
  29.  
  30.     if (strcmp(argv[3], "encrypt") == 0)
  31.     {
  32.         i = 0;
  33.         while(i <= strlen(string)-1)
  34.         {
  35.             encrypted_string[i] = string[i]+ key_int;
  36.             i++;
  37.         }
  38.        
  39.         printf("Encrypted String: ");
  40.         i = 0;
  41.         while (i <= strlen(string)-1 )
  42.         {  
  43.             printf("%c", encrypted_string[i]);
  44.             i++;
  45.         }
  46.         printf("\n");
  47.     }
  48.     if (strcmp(argv[3], "decrypt") == 0)
  49.     {
  50.         i = 0;
  51.         while(i <= strlen(string)-1)
  52.         {
  53.             decrypted_string[i] = string[i] - key_int;
  54.             i++;
  55.         }  
  56.        
  57.         printf("Decrypted String: ");
  58.         i = 0;
  59.         while(i <= strlen(string)-1)
  60.         {
  61.             printf("%c", decrypted_string[i]);
  62.             i++;
  63.         }
  64.  
  65.         printf("\n");
  66.     }
  67. }
RAW Paste Data