I want to save Crypto++ keys to std::vector
. Unfortunately there is only CryptoPP::StringSink
, that takes std::string
refer
Working implementation of VectorSink
// Written and placed in the public domain by rrmmnn
// Copyright assigned to the Crypto++ project.
namespace CryptoPP {
class VectorSink : public Bufferless<Sink> {
public:
VectorSink(std::vector<uint8_t>& out)
: _out(&out) {
}
size_t Put2(const byte *inString, size_t length, int /*messageEnd*/, bool /*blocking*/) {
_out->insert(_out->end(), inString, inString + length);
return 0;
}
private:
std::vector<uint8_t>* _out;
};
}