📄 es_file.cpp
字号:
/************************************************** 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -