es_file.cpp
来自「含有多种公开密钥算法、多种块加密、多种数据流加密、多种HASH函数、多种Chec」· C++ 代码 · 共 55 行
CPP
55 行
/************************************************** File EntropySource Source File ** (C) 1999-2002 The Botan Project **************************************************/#include <botan/es_file.h>#include <fstream>namespace Botan {/************************************************** File_EntropySource Constructor **************************************************/File_EntropySource::File_EntropySource(bool add_defaults, const std::string& source) { if(source != "") add_source(source); if(add_defaults) { add_source("/dev/urandom"); add_source("/dev/random"); } }/************************************************** Gather Entropy from Randomness Source **************************************************/u32bit File_EntropySource::slow_poll(byte output[], u32bit length) { u32bit read = 0; for(u32bit j = 0; j != sources.size(); j++) { std::ifstream random_source(sources[j].c_str()); if(!random_source) continue; random_source.read((char*)output + read, length); read += random_source.gcount(); length -= random_source.gcount(); if(length == 0) break; } return read; }/************************************************** Add another source **************************************************/void File_EntropySource::add_source(const std::string& source) { sources.push_back(source); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?