Advertisement
Mizuhara_Chizuru

Project progress v1

Oct 17th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. /*Code by Surya a.k.a Sunny*/
  2. /* by https://www.codechef.com/users/spsc */
  3. #include <bits/stdc++.h>
  4. #include<string.h>
  5. //#include <boost/multiprecision/cpp_int.hpp>
  6. #define lli long long
  7. #define pi 3.14159265358979323846
  8. #define MOD 1000000007
  9. #define foi(n)  for(lli i=0;i<n;i++)
  10. #define foj(n)  for(lli j=0;j<n;j++)
  11. #define test(T) lli T;cin>>T;while(T--)
  12. #define loop(i, a, b) for(int i = (a); i<= (b); i++)
  13. #define unbuffer cin.clear(); cin.sync();
  14. using namespace std;
  15. //using namespace boost::multiprecision;
  16. int main()
  17. {
  18.   //ios_base::sync_with_stdio(false);
  19.    //cin.tie(NULL);
  20.    //cout.tie(NULL);
  21.    lli a,i=0,temp,len;
  22.    string str;
  23.    char x;
  24.  
  25.    cout<<"DATA ENCRYPTION SOFTWARE v1.00\n\n\n";
  26.    //gotoxy(24,30);
  27.    cout<<"Choose from one of the options below : \n\n\n";
  28.    cout<<" 1.  Enter a text \n";
  29.    cout<<" 2. Choose a .txt or .dat (binary) file by giving its name and extension \n\n\n \t";
  30.  
  31.    cin>>a;
  32.  
  33.    /*---------X------------X-----------X-----------X----------X----------X--------X---------*/
  34.  
  35.    system("cls");
  36.    if(a==1)
  37.     {
  38.       cout<<"Enter your text below : \n";
  39.       unbuffer
  40.       getline(cin,str);
  41.       len=str.length();
  42.       str[len]='\0';
  43.       char enc[len],dec[len];
  44.       while(i<len)
  45.         {
  46.           /*switch(str[i])
  47.             {
  48.               case 's':
  49.                 enc[i]='m';
  50.                 break;
  51.               case 'u':
  52.                 enc[i]='n';
  53.                 break;
  54.               case 'r':
  55.                 enc[i]='g';
  56.                 break;
  57.               case 'y':
  58.                 enc[i]='l';
  59.                 break;
  60.               case 'a':
  61.                 enc[i]='p';
  62.                 break;
  63.             }
  64.           */
  65.           temp=str[i];
  66.           temp+=i;
  67.           x=(char)temp;
  68.           //cout<<x;
  69.           enc[i]=x; //*********************************
  70.           i++;
  71.         }
  72.       cout<<str<<'\n';
  73.       cout<<enc<<'\n';
  74.     i=0;
  75.  
  76. /*---------X------------X-----------X-----------X----------X----------X--------X---------*/
  77.  
  78.  
  79.     while(i<len)
  80.       {
  81.         temp=enc[i];
  82.         temp-=i;
  83.         x=(char)temp;
  84.         dec[i]=x;
  85.         i++;
  86.       }
  87.     dec[len]='\0';
  88.     cout<<dec;
  89.  }
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement