//Additive Cipher brute force attack
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
int main()
{
int key;
string plainText, cipherText;
//freopen("input.txt","r",stdin);
while(cin>>cipherText){
int len = cipherText.size();
for(key = 1; key<26; key++){
plainText = "";
for(int i=0; i<len; i++){
int x = (cipherText[i] - 'A' - key) % 26;
if(x < 0) x += 26;
plainText += (x + 'a');
}
cout<<"Key = "<<key<<" PlainText = "<<plainText<<endl;
}
}
return 0;
}
Saturday, July 27, 2013
Additive Cipher Decryption by brute force attack
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment