Сохранение объектов Crypto ++ в std :: vector
Я хочу сохранить ключи Crypto ++ вstd::vector<uint8_t>
, К сожалению есть толькоCryptoPP::StringSink
, что занимаетstd::string
ссылка, но нетCryptoPP::VectorSink
это будет ссылаться наstd::vector
.
Следующий код работает нормально
std::string spki;
CryptoPP::StringSink ss(spki);
CryptoPP::RSA::PublicKey publicKey(...);
publicKey.Save(ss);
Но я хочу этого
std::vector<uint8_t> spki;
CryptoPP::VectorSink vs(spki);
CryptoPP::RSA::PublicKey publicKey(...);
publicKey.Save(vs);
Эта проблема
VectorSink
не может быть создан только с помощью typedef из-заtraits_type::char_type
внутриStringSinkTemplate
:
using CryptoPP::StringSinkTemplate;
typedef StringSinkTemplate< std::vector<byte> > VectorSink;
In file included from cryptopp-test.cpp:65:
In file included from /usr/local/include/cryptopp/files.h:5:
/usr/local/include/cryptopp/filters.h:590:22: error: no member named
'traits_type' in 'std::vector<unsigned char, std::allocator<unsigned char>
>'
typedef typename T::traits_type::char_type char_type;
~~~^
cryptopp-test.cpp:243:20: note: in instantiation of template class
'CryptoPP::StringSinkTemplate<std::vector<unsigned char,
std::allocator<unsigned char> > >' requested here
VectorSink vs(spki);
Как я могу создатьVectorSink
?