Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //Vigenere Cipher
- int main(){
- string s,keyWord;
- cin>>s>>keyWord;
- for(int i=0;i<keyWord.length();i++){
- if(keyWord[i]>=97&&keyWord[i]<=122)
- keyWord[i]-=32;
- }
- string key=keyWord;
- while(key.length()<s.length())
- key+=keyWord;
- char a[26][26];
- char c;
- char d='A';
- for(int i=0;i<26;i++){
- c=d;
- for(int j=0;j<26;j++){
- a[i][j]=c;
- if(c=='Z'){
- c='A';
- c--;
- }
- c++;
- }
- d++;
- }
- string plainText;
- for(int i=0;i<s.length();i++){
- int x=key[i]-65;
- for(int j=0;j<26;j++){
- if(a[x][j]==s[i]){
- plainText[i]=j+65;
- break;
- }
- }
- cout<<plainText[i];
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment