Using cryptographic streams in C++

不羁的心 提交于 2019-12-01 00:16:34

Implement your own istream using crypto++.

crypto++'s FileSource class takes std::istream& in the constructor, so it seems that you are done.

FileSource (std::istream &in, bool pumpAll, 
    BufferedTransformation *attachment=NULL)

EDIT

if you are asking how to use a hash function on istream in cryptopp, here's a sample taken from cryptopp wiki, modified by me for use with istream:

#include "sha.h"
#include "files.h"

std::string digest;

CryptoPP::SHA256 hash;

CryptoPP::FileSource(in, true,   // true here means consume all input at once 
   new CryptoPP::HashFilter(hash,
         new CryptoPP::StringSink(digest)));

std::cout << digest << std::endl;

This will read the stream in until eof, pass it through a hash filter and finally the result will enf up in the digest string.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!