2 つの単純な暗号解読機能があります。関数はテキスト ファイルに対して正常に機能し、ファイルを正常に取得できます。ただし、バイナリファイルが破損します。イメージを暗号化してから復号化すると、イメージが破損します。
bool Encrypter::FileEncrypter(std::string src, std::string dest)
{
try {
Botan::InitializationVector iv(enckey.substr(0,32));
Botan::SymmetricKey symKey(enckey.substr(32,32));
Botan::DataSource_Stream in(src.c_str(), true);
Botan::Pipe enc(Botan::get_cipher("AES-128/CBC", symKey, iv, Botan::ENCRYPTION), new Botan::DataSink_Stream(dest.c_str()));
enc.process_msg(in);
return true;
}
catch(std::exception &e){
return false;
}
}
bool Encrypter::FileDecrypter(std::string src, std::string dest)
{
try {
Botan::InitializationVector iv(enckey.substr(0,32));
Botan::SymmetricKey symKey(enckey.substr(32,32));
Botan::DataSource_Stream in(src.c_str(), true);
Botan::Pipe dec(Botan::get_cipher("AES-128/CBC", symKey, iv, Botan::DECRYPTION), new Botan::DataSink_Stream(dest.c_str()));
dec.process_msg(in);
return true;
}
catch(std::exception &e){
return false;
}
}