cryptography-utils/brute.cc
2023-10-24 21:38:29 +02:00

28 lines
452 B
C++

#include <iostream>
void shift(char* text, int key)
{
std::cout << key << ": ";
for(int i = 0; text[i] != 0; ++i)
{
char c = std::tolower(text[i])-key;
if(c < 'a') c+=26;
if(c > 'z') c-=26;
std::cout << c;
}
std::cout << std::endl;
}
int main(int argc, char** argv)
{
if(argc < 2)
{
std::cout << "Usage: " << argv[0] << " <ciphertext>" << std::endl;
return 0;
}
for(int i = 1; i < 26; ++i)
{
shift(argv[1], i);
}
return 0;
}