Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Code by Surya a.k.a Sunny*/
- /* by https://www.codechef.com/users/spsc */
- #include <bits/stdc++.h>
- #include<string.h>
- //#include <boost/multiprecision/cpp_int.hpp>
- #define lli long long
- #define pi 3.14159265358979323846
- #define MOD 1000000007
- #define foi(n) for(lli i=0;i<n;i++)
- #define foj(n) for(lli j=0;j<n;j++)
- #define test(T) lli T;cin>>T;while(T--)
- #define loop(i, a, b) for(int i = (a); i<= (b); i++)
- #define unbuffer cin.clear(); cin.sync();
- using namespace std;
- //using namespace boost::multiprecision;
- int main()
- {
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- //cout.tie(NULL);
- lli a,i=0,temp,len;
- string str;
- char x;
- cout<<"DATA ENCRYPTION SOFTWARE v1.00\n\n\n";
- //gotoxy(24,30);
- cout<<"Choose from one of the options below : \n\n\n";
- cout<<" 1. Enter a text \n";
- cout<<" 2. Choose a .txt or .dat (binary) file by giving its name and extension \n\n\n \t";
- cin>>a;
- /*---------X------------X-----------X-----------X----------X----------X--------X---------*/
- system("cls");
- if(a==1)
- {
- cout<<"Enter your text below : \n";
- unbuffer
- getline(cin,str);
- len=str.length();
- str[len]='\0';
- char enc[len],dec[len];
- while(i<len)
- {
- /*switch(str[i])
- {
- case 's':
- enc[i]='m';
- break;
- case 'u':
- enc[i]='n';
- break;
- case 'r':
- enc[i]='g';
- break;
- case 'y':
- enc[i]='l';
- break;
- case 'a':
- enc[i]='p';
- break;
- }
- */
- temp=str[i];
- temp+=i;
- x=(char)temp;
- //cout<<x;
- enc[i]=x; //*********************************
- i++;
- }
- cout<<str<<'\n';
- cout<<enc<<'\n';
- i=0;
- /*---------X------------X-----------X-----------X----------X----------X--------X---------*/
- while(i<len)
- {
- temp=enc[i];
- temp-=i;
- x=(char)temp;
- dec[i]=x;
- i++;
- }
- dec[len]='\0';
- cout<<dec;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement