使用 Gronsveld 密码,例如,使用 Sony 这个词的加密和密钥 23,密码是正确的,但超出了字母表
void encryt()
{
string encryptedText;
for (int j = 0; Key.size() < Word.size(); j++)
{
Key.push_back(Key[j]);
}
for (int i = 0; i < Word.size(); i++)
{
if (Word[i] == ' ')
{
encryptedText.push_back(' ');
}
else
{
encryptedText.push_back(char((Word[i]) + Key[i] - 48));
}
}
cout << "\nText: " << "\t" << Word << endl;
cout << "Key: " << "\t" << Key << endl;
cout << "\nEncrypted Text: " << encryptedText << endl;
this->encryptedText = encryptedText;
}
控制台输出
Text: Sony
Key: 2323
Encrypted Text: Urp|
Decrypted Text: Sony