Advertisement
Guest User

DECRIPTARE

a guest
Nov 10th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.15 KB | None | 0 0
  1.                             #include <iostream>
  2.                             #include <string>
  3.                             #include <conio.h>
  4.                             #include <ctime>
  5.                             #include <cstdlib>
  6.                             #include <string.h>
  7.  
  8.                     using namespace std;
  9.  
  10.                     int main()
  11.                     {/*
  12. qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890
  13. 01234567890123456789012345678901234567890123456789012345678901
  14. */
  15.                       string alfabeto = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
  16.                       string codice = "EhxkxYdq397oo0";
  17.                       string chiave = "rosarosarosaro";
  18.                       string finale = "";
  19.                       //cout << "Inserisci chiave :";
  20.                       //cin >> chiave;
  21.                       //cout << "Inserisci codice :";
  22.                       //cin >> codice;
  23.  
  24.  
  25.                       for (int i = 0;i!=codice.size();i++){
  26.                             char lettera;
  27.                             bool carattereSpeciale = true;
  28.  
  29.                             for(int a = 0; a != alfabeto.length();a++){
  30.                                     if (codice[i] == alfabeto[a]){
  31.                                         carattereSpeciale = false;
  32.                                         break;
  33.                                     }
  34.                             }
  35.  
  36.  
  37.  
  38.                             if (carattereSpeciale) {
  39.  
  40.                     lettera = ' ';
  41.                     cout << "#" << endl;
  42.                             } else {
  43.                                             int posCodice;
  44.                                             int posChiave;
  45.  
  46.                                             for(int a = 0; a != alfabeto.length();a++){
  47.                                                 if (alfabeto[a] == codice[i]){
  48.                                                     posCodice = a;
  49.                                                     break;
  50.                                                 }
  51.                                             }
  52.  
  53.                                             for(int b = 0; b != alfabeto.length();b++){
  54.                                                 if (alfabeto[b] == chiave[i]){
  55.                                                     posChiave = b;
  56.                                                     break;
  57.                                                 }
  58.                                             }
  59.  
  60.                                             int posAlfa = posCodice - posChiave;
  61.                                                 lettera = alfabeto[posAlfa];
  62.                                             //lettera = alfabeto[posAlfa-((posAlfa/alfabeto.length())*alfabeto.length())];
  63.                                             cout << posCodice << " - " << posChiave << " = " << posAlfa << " / " << lettera << endl;
  64.  
  65.                                     }
  66.  
  67.                             //finale.push_back(lettera);
  68.                       }
  69.                       //cout << finale << endl;
  70.                       system("pause");
  71.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement