23 #include <cryptopp/aes.h>
24 #include <cryptopp/filters.h>
25 #include <cryptopp/pwdbased.h>
26 #include <cryptopp/modes.h>
27 #include <cryptopp/sha.h>
40 CryptoPP::PKCS5_PBKDF2_HMAC<CryptoPP::SHA256>().DeriveKey(target.data(), target.size(), 0, pw.data(), pw.size(), _salt.
data(), _salt.
size(), _rounds);
44 CryptoPP::AES::Decryption aesDecryption(target.data(), 16);
45 auto cipher = _ivCipher.
cropped(16);
46 auto iv = _ivCipher.
cropped(0, 16);
47 CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data());
48 std::string decrypted;
49 CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption,
new CryptoPP::StringSink(decrypted));
50 stfDecryptor.Put(cipher.data(), cipher.size());
51 stfDecryptor.MessageEnd();
54 catch (std::exception
const& e)
57 std::cerr << e.what() <<
'\n';