Saving Crypto++ objects to std::vector

前端 未结 1 1921
面向向阳花
面向向阳花 2021-01-22 02:59

I want to save Crypto++ keys to std::vector. Unfortunately there is only CryptoPP::StringSink, that takes std::string refer

相关标签:
1条回答
  • 2021-01-22 03:41

    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;
    };
    
    }
    
    0 讨论(0)
提交回复
热议问题