123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #include <iostream>
- using namespace std;
- string get_encrypted_text(string temp,int key)
- {
- int i,j,temp_integer;
- string op="";
- string alphabets="abcdefghijklmnopqrstuvwxyz",capital_alphabets="ABCDEFGHIJKLMNOPQRSTUVWXYZ",numbers="0123456789";
-
- for(i=0;temp[i]!='\0';i++)
- {
-
-
- if((int)temp[i]<=122&&(int)temp[i]>=97)
- {
- temp_integer=((int)temp[i]-97+key)%26;
- op+=alphabets[temp_integer];
- }
-
- else if((int)temp[i]>=65&&(int)temp[i]<=91)
- {
- temp_integer=((int)temp[i]-65+key)%26;
- op+=capital_alphabets[temp_integer];
- }
-
- else if((int)temp[i]>=48&&(int)temp[i]<=57)
- {
- temp_integer=((int)temp[i]-48+key)%10;
- op+=numbers[temp_integer];
- }
-
- else if((int)temp[i]==32)
- op+=" ";
-
- else
- op+=(char)((int)(temp[i])+key);
- }
-
- return op;
-
-
- }
- int main() {
- string op;
- int key;
- char ip[100];
-
- cout<<"Enter the String to be encrypted\n";
-
- cin.getline(ip,sizeof(ip));
-
- cout<<"\nEnter the key\n";
-
- cin>>key;
-
- op=get_encrypted_text(ip,key);
-
- cout<<"\nEncrypted String is "<<op<<endl<<"-----------------------------------------------------";
-
- for(int j=0;j<26;j++)
- {
- op=get_encrypted_text (op,1);
- cout<<"\nEncrypted combinations are "<<op<<endl;
-
- }
-
- return 0;
- }
- /*
- #include <iostream>
- #include <ctime>
-
- using namespace std;
-
- int main( )
- {
- // current date/time based on current system
- time_t now = time(0);
-
- // convert now to string form
- char* dt = ctime(&now);
-
- cout << "The local date and time is: " << dt << endl;
-
- // convert now to tm struct for UTC
- tm *gmtm = gmtime(&now);
- dt = asctime(gmtm);
- cout << "The UTC date and time is:"<< dt << endl;
- }
- */
|