42 CryptoPP::PKCS5_PBKDF2_HMAC<CryptoPP::SHA256>().DeriveKey(target.data(), target.size(), 0, pw.data(), pw.size(), _salt.
data(), _salt.
size(), _rounds);
46 CryptoPP::AES::Decryption aesDecryption(target.data(), 16);
47 auto cipher = _ivCipher.
cropped(16);
48 auto iv = _ivCipher.
cropped(0, 16);
49 CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data());
50 std::string decrypted;
51 CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption,
new CryptoPP::StringSink(decrypted));
52 stfDecryptor.Put(cipher.data(), cipher.size());
53 stfDecryptor.MessageEnd();
56 catch (exception
const&
e)
58 cerr << e.what() << endl;
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Class file for modes of operation.
std::hash for asio::adress
vector_ref< _T > cropped(size_t _begin, size_t _count) const
Class file for the AES cipher (Rijndael)
std::vector< byte > bytes
bytes asBytes(std::string const &_b)
Converts a string to a byte array containing the string's (byte) data.
Classes for SHA-1 and SHA-2 family of message digests.
Implementation of BufferedTransformation's attachment interface.
Password based key derivation functions.
bytes aesDecrypt(bytesConstRef _cipher, std::string const &_password, unsigned _rounds=2000, bytesConstRef _salt=bytesConstRef())