dvdg6566

Untitled

Jun 18th, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int c,d;
  4.  
  5. void vignere(string a, string b){
  6.   c = a.length();
  7.   d = b.length();
  8.   for (int i = 0; i < c; ++i){
  9.     int e = a[i] - 64, f = b[i%d] - 64;;
  10.     if(a[i] == ' ')e=0;
  11.     if(b[i] == ' ')f=0;
  12.     int x = (e+f)%27;
  13.     char t = x + '@';
  14.     if(x==0){cout << ' ';continue;}
  15.     cout << t;
  16.   }
  17. }
  18.  
  19. int main(){
  20.   string a,b;
  21.   cout << "Enter Message to encrypt: ";
  22.   getline(cin,a);
  23.   cout << "Enter keyword: ";
  24.   getline(cin,b);
  25.   vignere(a,b);
  26. }
Add Comment
Please, Sign In to add comment